This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: ResultTreeFrag to String
- To: Honglin Su <hosu at csee dot umbc dot edu>
- Subject: Re: ResultTreeFrag to String
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Mon, 04 Sep 2000 21:51:57 +0100
- Cc: XSL List <XSL-List at mulberrytech dot com>
- Reply-To: xsl-list at mulberrytech dot com
Honglin,
>If the node has a text child, I will get the sub-tree (String
>representation) of the node, and pass it to a Java extenstion.
I may well be wrong, but I think that by 'string representation' you mean a
string that looks the same as the original serialised XML? To do this, you
need a template that will take an XML tree and produce the serialised
version of the tree. There's no straight-forward way to do this in XSLT -
no automated way of producing a serialised representation of the tree. But
you can do it by hand using:
<xsl:template match="*" mode="serialise">
<xsl:value-of select="concat('<', name())" />
<xsl:for-each select="@*">
<xsl:value-of select="concat(' ', name(), '="', ., '"')" />
</xsl:for-each>
<xsl:text>></xsl:text>
<xsl:apply-templates />
<xsl:value-of select="concat('</', name(), '>')" />
</xsl:template>
or something similar (might be wise to escape quotes within the attribute
values, for example).
A final note on terminology. Usually when we're talking about XSLT, the
'string value' of an element is the value of its content, and its
descendent elements' content, so the 'string value' of the Lease element in:
<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>
is
"
ABC Industries
agrees to lease the property at
123 Main St., Chicago, IL
from
XYZ Properties
for a term of not less than
18
at a cost of
1000
.
"
This is why I find your question confusing :)
I hope that this helps anyway,
Jeni
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list