[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: ResultTreeFrag to String

Subject: Re: ResultTreeFrag to String
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 04 Sep 2000 21:51:57 +0100
Re: ResultTreeFrag to String
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('&lt;', name())" />
  <xsl:for-each select="@*">
    <xsl:value-of select="concat(' ', name(), '=&quot;', ., '&quot;')" />
  </xsl:for-each>
  <xsl:text>&gt;</xsl:text>
  <xsl:apply-templates />
  <xsl:value-of select="concat('&lt;/', name(), '&gt;')" />
</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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.