[jdom-interest] Problem with Jdom8 - getChildren() on root do
esn't work...
Deepali Abhyankar
dabhyankar at amadeusboston.com
Thu Mar 28 10:17:25 PST 2002
Hmm. Quick question - what jar files are you pointing to when you ran the
application below? Besides the jdom.jar for JDOM8.
Thanks,
- Deepali.
-----Original Message-----
From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
Sent: Thursday, March 28, 2002 12:04 PM
To: Deepali Abhyankar
Cc: jdom-interest at jdom.org; hip at a.cs.okstate.edu
Subject: Re: [jdom-interest] Problem with Jdom8 - getChildren() on root
do esn't work...
Hmmm, there has to be more to this story. I cann't reproduce a size()==0.
Here's the code I used and the output for a run with "etid.xml etid.xsl"
as input. Did I miss something?
Brad
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.transform.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class XSLTransform {
public static void main(String[] args) throws Exception {
SAXBuilder builder = new SAXBuilder();
Document doc1 = builder.build(args[0]);
Document doc2 = transform(doc1, args[1]);
Element root1 = doc1.getRootElement();
Element root2 = doc2.getRootElement();
System.out.println("root1.hasChildren()=" + root1.hasChildren());
System.out.println("root2.hasChildren()=" + root2.hasChildren());
List theChildren1 = root1.getChildren();
List theChildren2 = root2.getChildren();
System.out.println("root1 size()=" + theChildren1.size());
System.out.println("root2 size()=" + theChildren2.size());
XMLOutputter out = new XMLOutputter(" ", true);
out.setTextNormalize(true);
System.out.println("\n===== Document 1
====================================");
out.output(doc1, System.out);
System.out.println("\n\n===== Document 2
====================================");
out.output(doc2, System.out);
}
public static Document transform(Document in, String stylesheet)
throws JDOMException {
try {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(stylesheet));
JDOMResult out = new JDOMResult();
transformer.transform(new JDOMSource(in), out);
return out.getDocument();
}
catch (TransformerException e) {
throw new JDOMException("XSLT Transformation failed", e);
}
}
}
root1.hasChildren()=true
root2.hasChildren()=true
root1 size()=8
root2 size()=1
===== Document 1 ====================================
<?xml version="1.0" encoding="UTF-8"?>
<newsdata>
<date year="2002" month="3" day="27" hour="19" minute="6" second="32" />
<newsitem id="17117">
<title><![CDATA[Spanish islands attract 8m out of 14m UK
visits]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17117</url>
</newsitem>
<newsitem id="17116">
<title><![CDATA[Small airlines court small agents in US commission
fall-out]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17116</url>
</newsitem>
<newsitem id="17120">
<title><![CDATA[Thomas Cook UK turns over 184m in Nov/Dec/Jan
quarter]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17120</url>
</newsitem>
<newsitem id="17119">
<title><![CDATA[Another bidder circles QMH]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17119</url>
</newsitem>
<newsitem id="17118">
<title><![CDATA[Hertz expands into China]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17118</url>
</newsitem>
<newsitem id="17121">
<title><![CDATA[NTL offers ?no asssurance? of successful
bailout]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=17121</url>
</newsitem>
<newsitem id="1642">
<title><![CDATA[<A HREF=http://www.e-tid.com/travelweekly.asp>What the
trade papers say</A>]]></title>
<url>http://www.e-tid.com/viewarticle.asp?ID=1642</url>
</newsitem>
</newsdata>
===== Document 2 ====================================
<?xml version="1.0" encoding="UTF-8"?>
<dbUpdate xmlns:fo="http://www.w3.org/1999/XSL/Format">
<dbtransaction>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17117"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17117" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="Spanish islands attract 8m out of 14m UK visits"
name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17116"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17116" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="Small airlines court small agents in US commission
fall-out" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17120"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17120" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="Thomas Cook UK turns over 184m in Nov/Dec/Jan quarte
" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17119"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17119" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="Another bidder circles QMH
" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17118"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17118" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="Hertz expands into China" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=17121"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="17121" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="NTL offers ?no asssurance? of successful bailou
" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINK" schema="SITE">
<column value="" name="LINK_ID" />
<column value="C" name="LINKTYPE_E" />
<column value="F" name="EDITABLELINK_B" />
<column value="http://www.e-tid.com/viewarticle.asp?ID=1642"
name="LINKURL_S" />
<column value="" name="ENTERED_D" />
<column value="1642" name="ARTICLEKEY_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="LINKTEXT" schema="SITE">
<column value="" name="LINK_ID" />
<column value="en" name="LANGCODE_S" />
<column value="<A
HREF=http://www.e-tid.com/travelweekly.asp>What the trade papers
say</A>" name="LINKURLTEXT_S" />
</tableLocation>
</sqlStatement>
<sqlStatement action="">
<tableLocation table="URLGROUPLINK" schema="SITE">
<column value="" name="URLGROUP_ID" />
<column value="" name="LINK_ID" />
<column value="" name="SITE_ID" />
<column value="" name="URLPRIORITY_I" />
</tableLocation>
</sqlStatement>
</dbtransaction>
</dbUpdate>
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
More information about the jdom-interest
mailing list