[jdom-commits] CVS update: jdom/src/java/org/jdom/output

cvs at jools.org cvs at jools.org
Mon Feb 11 22:15:21 PST 2002


Date:	Tuesday February 12, 2002 @ 1:15
Author:	cvs

Update of /home/cvspublic/jdom/src/java/org/jdom/output
In directory jools.org:/tmp/cvs-serv25821/output

Modified Files:
	DOMOutputter.java 
Log Message:
Patch from Brad Huffman to help DOMBuilder and DOMOutputter better handle
fancy namespace situations.  This was triggered by a bug report from 
Xuemin Guan.

We're following a nicely conservative plan where DOMOutputter always sets 
a namespace and DOMBuilder never assumes it or a user's application did.
This also lets us be more compatible with DOM Level 1.

Below is a test file Brad wrote to demo the bug:

import java.util.List;

import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.input.DOMBuilder;
import org.jdom.output.DOMOutputter;
import org.jdom.output.XMLOutputter;

import java.io.FileInputStream;

import org.w3c.dom.Document;

public class Jdom2DomTest {
 public Jdom2DomTest(String fileName) throws Exception {
  Element root;
  List list;
  Element child;

  XMLOutputter outputter;

  SAXBuilder saxBuilder = new SAXBuilder();
  DOMBuilder domBuilder = new DOMBuilder();

  org.jdom.Document jdomDoc = saxBuilder.build(new FileInputStream(fileName));
  root = jdomDoc.getRootElement();
  list = root.getChildren();
  System.out.println("child(0) = " + (Element) list.get(0));
  System.out.println("child(1) = " + (Element) list.get(1));
  System.out.println("child(2) = " + (Element) list.get(2));
  outputter = new XMLOutputter();
  outputter.output(jdomDoc,System.out);

  DOMOutputter domOutputter = new DOMOutputter();
  org.w3c.dom.Document w3cDoc = domOutputter.output(jdomDoc);

  System.out.println(" ");
  jdomDoc = domBuilder.build(w3cDoc);
  root = jdomDoc.getRootElement();
  list = root.getChildren();
  System.out.println("child(0) = " + (Element) list.get(0));
  System.out.println("child(1) = " + (Element) list.get(1));
  System.out.println("child(2) = " + (Element) list.get(2));
  outputter = new XMLOutputter();
  outputter.output(jdomDoc,System.out);
 }

 public static void main(String[] args) throws Exception{
  if(args.length < 0) {
   System.out.println("Usage: java Jdom2DomTest filename");
   System.exit(1);
  }
  Jdom2DomTest tester = new Jdom2DomTest(args[0]);
 }
}


<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" version="1.0">
 <element name="SAPRDI01">
  <annotation>
   <documentation>SAPscript Raw Data Interface IDOC Type</documentation>
  </annotation>
 </element>
 <element name="SAPRDI02">
  <annotation>
   <documentation>SAPscript Raw Data Interface IDOC Type</documentation>
  </annotation>
 </element>
 <element name="SAPRDI03">
  <annotation>
   <documentation>SAPscript Raw Data Interface IDOC Type</documentation>
  </annotation>
 </element>
</schema>

-jh-

===================================================================
File: no file DOMOutputter.java		Status: Needs Checkout

   Working revision:	1.28	Tue Feb 12 06:15:21 2002
   Repository revision:	1.28	/home/cvspublic/jdom/src/java/org/jdom/output/DOMOutputter.java,v

   Existing Tags:
	jdom_prefilter           	(revision: 1.25)
	jdom_1_0_b7              	(revision: 1.25)
	jdom_1_0_b6              	(revision: 1.16)
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)




More information about the jdom-commits mailing list