[jdom-interest] JDOM XSLT

Mani Doraisamy MDoraisamy at SELECTICA.com
Wed Apr 17 07:40:17 PDT 2002


Thanks Laurent.
I am using xalan with JDOM. The problem is even if i give a
smaller chunk in the template match it seems to output the whole
tree

        Element root = new Element("Stock");
        root.addContent(new Element("Company").addContent("xyz"));
        root.addContent(new Element("Company").addContent("abc"));

        Element subRoot = new Element("Price");
        subRoot.addContent(new Element("List").addContent("$100"));
        subRoot.addContent(new Element("List").addContent("$200"));
        
        Element sub2Root = new Element("Demand");
        sub2Root.addContent(new Element("priority").addContent("low"));
        sub2Root.addContent(new Element("priority").addContent("high"));

        root.addContent(subRoot);
        root.addContent(sub2Root);

        Document doc = new Document(root);

for the xsl :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/Stock/Price">
<xsl:element name="SelectedPrice"><xsl:value-of select="List[2]"
/></xsl:element>
</xsl:template>
</xsl:stylesheet>

Outputs :

getText() being called for Company
getText() being called for Company
getText() being called for List
getText() being called for List
getText() being called for priority
getText() being called for priority

<?xml version="1.0" encoding="UTF-8"?>
xyzabc<SelectedPrice
xmlns:fo="http://www.w3.org/1999/XSL/Format">$200</Selected
Price>lowhigh

Is there anyway i can hide a part of the tree from being outputted every
time i do the
transformation?

mani

-----Original Message-----
From: Laurent Bihanic [mailto:laurent.bihanic at atosorigin.com]
Sent: Wednesday, April 17, 2002 4:54 PM
To: Mani Doraisamy
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] JDOM XSLT



Mani Doraisamy wrote:
> Hi all,
> I have a huge JDOM datastructure. when i do XSLT,
> does it output the whole tree or does it query only
> those mentioned in the stylesheet?

JDOM can't know the content of the stylesheet so it passes the whole
document 
content to the XSLT processor as a flow of SAX events. Based on that your
XSLT 
processor may choose to either rebuild the whole document in memory or
process 
it by small chunks. You may try different implementations.

It also depends on the way you wrote your stylesheets. If you have match 
statements that select large parts of the document, chances are good that
the 
XSLT processor requires the whole document to be loaded before stating
processing.

>  And how about namespace documents ?

There are no namespace documents. Namespace URIs are just unique
identifiers, 
they don't have to point to existing documents. XML parsers do not try to
load 
any data from namespace URIs.

Hope this helps,

Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020417/da1c01b5/attachment.htm


More information about the jdom-interest mailing list