<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [jdom-interest] JDOM XSLT</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Thanks Laurent.</FONT>
<BR><FONT SIZE=2>I am using xalan with JDOM. The problem is even if i give a</FONT>
<BR><FONT SIZE=2>smaller chunk in the template match it seems to output the whole</FONT>
<BR><FONT SIZE=2>tree</FONT>
</P>
<P><FONT SIZE=2> Element root = new Element("Stock");</FONT>
<BR><FONT SIZE=2> root.addContent(new Element("Company").addContent("xyz"));</FONT>
<BR><FONT SIZE=2> root.addContent(new Element("Company").addContent("abc"));</FONT>
</P>
<P><FONT SIZE=2> Element subRoot = new Element("Price");</FONT>
<BR><FONT SIZE=2> subRoot.addContent(new Element("List").addContent("$100"));</FONT>
<BR><FONT SIZE=2> subRoot.addContent(new Element("List").addContent("$200"));</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> Element sub2Root = new Element("Demand");</FONT>
<BR><FONT SIZE=2> sub2Root.addContent(new Element("priority").addContent("low"));</FONT>
<BR><FONT SIZE=2> sub2Root.addContent(new Element("priority").addContent("high"));</FONT>
</P>
<P><FONT SIZE=2> root.addContent(subRoot);</FONT>
<BR><FONT SIZE=2> root.addContent(sub2Root);</FONT>
</P>
<P><FONT SIZE=2> Document doc = new Document(root);</FONT>
</P>
<P><FONT SIZE=2>for the xsl :</FONT>
</P>
<P><FONT SIZE=2><?xml version="1.0" encoding="UTF-8"?></FONT>
<BR><FONT SIZE=2><xsl:stylesheet version="1.0" xmlns:xsl="<A HREF="http://www.w3.org/1999/XSL/Transform" TARGET="_blank">http://www.w3.org/1999/XSL/Transform</A>" xmlns:fo="<A HREF="http://www.w3.org/1999/XSL/Format" TARGET="_blank">http://www.w3.org/1999/XSL/Format</A>"></FONT></P>
<P><FONT SIZE=2><xsl:template match="/Stock/Price"></FONT>
<BR><FONT SIZE=2><xsl:element name="SelectedPrice"><xsl:value-of select="List[2]" /></xsl:element></FONT>
<BR><FONT SIZE=2></xsl:template></FONT>
<BR><FONT SIZE=2></xsl:stylesheet></FONT>
</P>
<P><FONT SIZE=2>Outputs :</FONT>
</P>
<P><FONT SIZE=2>getText() being called for Company</FONT>
<BR><FONT SIZE=2>getText() being called for Company</FONT>
<BR><FONT SIZE=2>getText() being called for List</FONT>
<BR><FONT SIZE=2>getText() being called for List</FONT>
<BR><FONT SIZE=2>getText() being called for priority</FONT>
<BR><FONT SIZE=2>getText() being called for priority</FONT>
</P>
<P><FONT SIZE=2><?xml version="1.0" encoding="UTF-8"?></FONT>
<BR><FONT SIZE=2>xyzabc<SelectedPrice xmlns:fo="<A HREF="http://www.w3.org/1999/XSL/Format" TARGET="_blank">http://www.w3.org/1999/XSL/Format</A>">$200</Selected</FONT>
<BR><FONT SIZE=2>Price>lowhigh</FONT>
</P>
<P><FONT SIZE=2>Is there anyway i can hide a part of the tree from being outputted every time i do the</FONT>
<BR><FONT SIZE=2>transformation?</FONT>
</P>
<P><FONT SIZE=2>mani</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Laurent Bihanic [<A HREF="mailto:laurent.bihanic@atosorigin.com">mailto:laurent.bihanic@atosorigin.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Wednesday, April 17, 2002 4:54 PM</FONT>
<BR><FONT SIZE=2>To: Mani Doraisamy</FONT>
<BR><FONT SIZE=2>Cc: jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: Re: [jdom-interest] JDOM XSLT</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2>Mani Doraisamy wrote:</FONT>
<BR><FONT SIZE=2>> Hi all,</FONT>
<BR><FONT SIZE=2>> I have a huge JDOM datastructure. when i do XSLT,</FONT>
<BR><FONT SIZE=2>> does it output the whole tree or does it query only</FONT>
<BR><FONT SIZE=2>> those mentioned in the stylesheet?</FONT>
</P>
<P><FONT SIZE=2>JDOM can't know the content of the stylesheet so it passes the whole document </FONT>
<BR><FONT SIZE=2>content to the XSLT processor as a flow of SAX events. Based on that your XSLT </FONT>
<BR><FONT SIZE=2>processor may choose to either rebuild the whole document in memory or process </FONT>
<BR><FONT SIZE=2>it by small chunks. You may try different implementations.</FONT>
</P>
<P><FONT SIZE=2>It also depends on the way you wrote your stylesheets. If you have match </FONT>
<BR><FONT SIZE=2>statements that select large parts of the document, chances are good that the </FONT>
<BR><FONT SIZE=2>XSLT processor requires the whole document to be loaded before stating processing.</FONT>
</P>
<P><FONT SIZE=2>> And how about namespace documents ?</FONT>
</P>
<P><FONT SIZE=2>There are no namespace documents. Namespace URIs are just unique identifiers, </FONT>
<BR><FONT SIZE=2>they don't have to point to existing documents. XML parsers do not try to load </FONT>
<BR><FONT SIZE=2>any data from namespace URIs.</FONT>
</P>
<P><FONT SIZE=2>Hope this helps,</FONT>
</P>
<P><FONT SIZE=2>Laurent</FONT>
</P>
</BODY>
</HTML>