You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jk...@apache.org on 2001/05/10 23:30:19 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/dtm ComposeDTM.java TestDTM.java
jkesselm 01/05/10 14:30:19
Modified: java/src/org/apache/xml/dtm Tag: DTM_EXP ComposeDTM.java
TestDTM.java
Log:
Clean up SAXException handling in the test drivers
Revision Changes Path
No revision
No revision
1.1.2.3 +51 -30 xml-xalan/java/src/org/apache/xml/dtm/Attic/ComposeDTM.java
Index: ComposeDTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/ComposeDTM.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ComposeDTM.java 2001/05/09 22:02:52 1.1.2.2
+++ ComposeDTM.java 2001/05/10 21:30:16 1.1.2.3
@@ -4,6 +4,10 @@
* - set DTMStringPool pointers
* - create element and text nodes with default append
* - dump the content of the DTM document created
+ *
+ * Rewritten to create the document via a simulated SAX2 stream rather than
+ * using "internal" DTM interfaces.
+ *
*<P>Status - work in progress</p>
*/
import org.apache.xml.dtm.CustomStringPool;
@@ -73,36 +77,53 @@
// compose a PurchaseOrder document
public void composeDoc() {
int root, h, c1, c2, c3, c4, c1_text, c2_text, c3_text, c4_text;
-
- root = newDoc.createElement("PurchaseOrderList", null);
- // root.createAttribute("version", "1.1"));
-
- for (int i = 0; i < 10; i++) {
-
- h = newDoc.createElement("PurchaseOrder", null);
-
- c1 = newDoc.createElement("Item", null);
- // c1.createAttribute();
- c1_text = newDoc.createTextNode("Basketball" + " - " + i);
- newDoc.endElement(null, "Item");
-
- c2 = newDoc.createElement("Description", null);
- // c2.createAttribute();
- c2_text = newDoc.createTextNode("Professional Leather Michael Jordan Signatured Basketball");
- newDoc.endElement(null, "Description");
-
- c3 = newDoc.createElement("UnitPrice", null);
- c3_text = newDoc.createTextNode("$12.99");
- newDoc.endElement(null, "UnitPrice");
-
- c4 = newDoc.createElement("Quanity", null);
- c4_text = newDoc.createTextNode("50");
- newDoc.endElement(null, "Quanity");
-
- newDoc.endElement(null, "PurchaseOrder");
- }
-
- newDoc.endElement(null, "PurchaseOrderList");
+ String text;
+
+ try
+ {
+
+ newDoc.startDocument();
+
+ newDoc.startElement(null,"PurchaseOrderList","PurchaseOrderList", null);
+ // root.createAttribute("version", "1.1"));
+
+ for (int i = 0; i < 10; i++) {
+
+ newDoc.startElement(null,"PurchaseOrder","PurchaseOrder", null);
+
+ newDoc.startElement(null,"Item","Item", null);
+ // c1.createAttribute();
+ text="Basketball" + " - " + i;
+ newDoc.characters(text.toCharArray(),0,text.length());
+ newDoc.endElement(null, "Item", "Item");
+
+ newDoc.startElement(null,"Description","Description", null);
+ // c2.createAttribute();
+ text="Professional Leather Michael Jordan Signatured Basketball";
+ newDoc.characters(text.toCharArray(),0,text.length());
+ newDoc.endElement(null, "Description", "Description");
+
+ newDoc.startElement(null,"UnitPrice","UnitPrice", null);
+ text="$12.99";
+ newDoc.characters(text.toCharArray(),0,text.length());
+ newDoc.endElement(null, "UnitPrice", "UnitPrice");
+
+ newDoc.startElement(null,"Quantity","Quantity", null);
+ text="50";
+ newDoc.characters(text.toCharArray(),0,text.length());
+ newDoc.endElement(null, "Quantity", "Quantity");
+
+ newDoc.endElement(null, "PurchaseOrder", "PurchaseOrder");
+ }
+
+ newDoc.endElement(null, "PurchaseOrderList", "PurchaseOrderList");
+
+ newDoc.endDocument();
+ }
+ catch(org.xml.sax.SAXException e)
+ {
+ e.printStackTrace();
+ }
}
// traverse the PurchaseOrder document and print out the content
1.1.2.7 +62 -54 xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTM.java
Index: TestDTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTM.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- TestDTM.java 2001/05/10 20:09:26 1.1.2.6
+++ TestDTM.java 2001/05/10 21:30:16 1.1.2.7
@@ -29,77 +29,85 @@
* </top> */
DTMDocumentImpl doc = new DTMDocumentImpl(0);
- doc.startDocument();
- doc.startElement("", "top", "top", null);
+ try
+ {
+ doc.startDocument();
- doc.startElement("", "A", "A", null);
+ doc.startElement("", "top", "top", null);
- AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("", "", "hat", "CDATA", "new");
- atts.addAttribute("", "", "car", "CDATA", "Honda");
- atts.addAttribute("", "", "dog", "CDATA", "Boxer");
- doc.startElement("","B","B", atts);
- text="Life is good";
- doc.characters(text.toCharArray(),0,text.length());
- doc.endElement("","B","B");
-
- doc.endElement("","A","A");
- doc.startElement("","C","C", null);
-
- text="My Anaconda";
- doc.characters(text.toCharArray(),0,text.length());
- doc.startElement("","D","D",null);
- doc.endElement("","D","D");
- text="Words";
- doc.characters(text.toCharArray(),0,text.length());
-
- doc.endElement("", "C", "C");
- doc.endElement("", "top", "top");
- doc.endDocument();
+ doc.startElement("", "A", "A", null);
- boolean BUILDPURCHASEORDER=false;
- if(BUILDPURCHASEORDER)
- {
- int root, h, c1, c2, c3, c4, c1_text, c2_text, c3_text, c4_text;
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute("", "", "hat", "CDATA", "new");
+ atts.addAttribute("", "", "car", "CDATA", "Honda");
+ atts.addAttribute("", "", "dog", "CDATA", "Boxer");
+ doc.startElement("","B","B", atts);
+ text="Life is good";
+ doc.characters(text.toCharArray(),0,text.length());
+ doc.endElement("","B","B");
+
+ doc.endElement("","A","A");
+ doc.startElement("","C","C", null);
+
+ text="My Anaconda";
+ doc.characters(text.toCharArray(),0,text.length());
+ doc.startElement("","D","D",null);
+ doc.endElement("","D","D");
+ text="Words";
+ doc.characters(text.toCharArray(),0,text.length());
- doc.startElement(null,"PurchaseOrderList","PurchaseOrderList", null);
+ doc.endElement("", "C", "C");
- for (int i = 0; i < 10; i++) {
+ boolean BUILDPURCHASEORDER=false;
+ if(BUILDPURCHASEORDER)
+ {
+ int root, h, c1, c2, c3, c4, c1_text, c2_text, c3_text, c4_text;
- doc.startElement("","PurchaseOrder","PurchaseOrder", null);
+ doc.startElement(null,"PurchaseOrderList","PurchaseOrderList", null);
- doc.startElement("","Item","Item", null);
- text="Basketball" + " - " + i;
- doc.characters(text.toCharArray(),0,text.length());
+ for (int i = 0; i < 10; i++) {
+
+ doc.startElement("","PurchaseOrder","PurchaseOrder", null);
+
+ doc.startElement("","Item","Item", null);
+ text="Basketball" + " - " + i;
+ doc.characters(text.toCharArray(),0,text.length());
- doc.endElement("", "Item", "Item");
+ doc.endElement("", "Item", "Item");
- doc.startElement("","Description","Description", null);
- // c2.createAttribute();
- text="Professional Leather Michael Jordan Signatured Basketball";
- doc.characters(text.toCharArray(),0,text.length());
+ doc.startElement("","Description","Description", null);
+ // c2.createAttribute();
+ text="Professional Leather Michael Jordan Signatured Basketball";
+ doc.characters(text.toCharArray(),0,text.length());
- doc.endElement("", "Description", "Description");
+ doc.endElement("", "Description", "Description");
- doc.startElement("","UnitPrice","UnitPrice", null);
- text="$12.99";
- doc.characters(text.toCharArray(),0,text.length());
+ doc.startElement("","UnitPrice","UnitPrice", null);
+ text="$12.99";
+ doc.characters(text.toCharArray(),0,text.length());
- doc.endElement("", "UnitPrice", "UnitPrice");
+ doc.endElement("", "UnitPrice", "UnitPrice");
- doc.startElement("","Quantity","Quantity", null);
- text="50";
- doc.characters(text.toCharArray(),0,text.length());
+ doc.startElement("","Quantity","Quantity", null);
+ text="50";
+ doc.characters(text.toCharArray(),0,text.length());
- doc.endElement("", "Quantity", "Quantity");
+ doc.endElement("", "Quantity", "Quantity");
- doc.endElement("", "PurchaseOrder", "PurchaseOrder");
- }
+ doc.endElement("", "PurchaseOrder", "PurchaseOrder");
+ }
- doc.endElement("", "PurchaseOrderList", "PurchaseOrderList");
- } // if(BUILDPURCHASEORDER)
-
+ doc.endElement("", "PurchaseOrderList", "PurchaseOrderList");
+ } // if(BUILDPURCHASEORDER)
+
+ doc.endElement("", "top", "top");
+ doc.endDocument();
+ }
+ catch(org.xml.sax.SAXException e)
+ {
+ e.printStackTrace();
+ }
TestDTMNodes.printNodeTable(doc);
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org