This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How to work with the element which has multiple child text nodes
- To: XSL-List at mulberrytech dot com
- Subject: How to work with the element which has multiple child text nodes
- From: Honglin Su <hosu at csee dot umbc dot edu>
- Date: Mon, 17 Jul 2000 16:35:18 -0400 (EDT)
- Reply-To: xsl-list at mulberrytech dot com
Hi, there,
Suppose that I have a document-centric XML document, one element node
might have multiple child text nodes and other child nodes as well, and
the order is also important.
e.g.: lease.xml
<?xml version="1.0" standalone="yes" ?>
<Lease>
<Lessee>ABC Industries</Lessee>
agrees to lease the property at
<Address>123 Main St., Chicago, IL</Address>
from
<Lessor>XYZ Properties</Lessor>
for a term of not less than
<LeaseTerm TimeUnit="Months">18</LeaseTerm>
at a cost of
<Price Currency="USD" TimeUnit="Months">1000</Price>
.
</Lease>
When I apply an XSL stylesheet to process the XML document, if such a node
is found (whenever a node has child text node), the whole sub-tree will
be passed to Java extension class to process.
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:storexml="storeXML" extension-element-prefixes="storexml">
<xsl:strip-space elements="*" />
<lxslt:component prefix="storexml" functions="testInsert closeConn
insertDB">
<lxslt:script lang="javaclass" src="storeXML" />
</lxslt:component>
<xsl:template match="/">
<xsl:apply-templates />
<xsl:value-of select="storexml:closeConn()" />
Successful!!!!!
</xsl:template>
<!-- process the children
-->
<xsl:template match="*">
<xsl:value-of select="storexml:insertDB(.., ., text(), @*)" />
<xsl:apply-templates />
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
Can anyone help me modify this stylesheet? What kind of parameter should
be passed on the extension class and how to keep the whole sub-tree so
that I can do further processing.
Is there any way that after I pass the parameter to Java extension
class, I could get the String representation of the sub-tree from the
current node, e.g.
<Lease>
<Lessee>ABC Industries</Lessee>
agrees to lease the property at
<Address>123 Main St., Chicago, IL</Address>
from
<Lessor>XYZ Properties</Lessor>
for a term of not less than
<LeaseTerm TimeUnit="Months">18</LeaseTerm>
at a cost of
<Price Currency="USD" TimeUnit="Months">1000</Price>
.
</Lease>
Thank you very much!
Honglin
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list