Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Converting a node tree to a textual representation

From: "Houghton,Andrew" <houghtoa@-------->
To:
Date: 9/3/2006 5:19:00 AM
I'm using XSL 2.0 to create a CSV text file.  One of the columns needs to be a
textual representation of a portion of the source document.  The source
document looks something like:

<doc>
  <lvl>
    <rec>
      <sect1/>
      <sect2/>
      <sect3/>
    </rec>
    <rec>
      <sect1/>
      <sect2/>
      <sect3/>
    </rec>
    <rec>
      <sect1/>
      <sect2/>
      <sect3/>
    </rec>
  </lvl>
</doc>

The CSV is suppose to look something like:

col1value,col2value,<rec><sect1/><sect2/><sect3/></rec>
col1value,col2value,<rec><sect1/><sect2/><sect3/></rec>
col1value,col2value,<rec><sect1/><sect2/><sect3/></rec>

The last column contains the textual representation of each of the <rec> nodes
in the source document.  Building the CSV structure is simple, but I haven't
quite figured out an easy way to convert the <rec> nodes in the tree to their
textual representation.  So I have some XSL that looks like:

<xsl:for-each select="rec">
  <xsl:variable name="col1" as="xsd:string" select="string('col1value')"/>
  <xsl:variable name="col2" as="xsd:string" select="string('col2value')"/>
  <xsl:variable name="col3" as="element()"  select="."/>
  <xsl:value-of select="concat($col1,$col2,$col3,'&#10;')"/>
</xsl:for-each>

Obviously, that variable for col3 doesn't make it happen.  Does anyone know of
an easy way to do this without writing a recursive template that goes through
the entire <rec> node set, which happens to have quite a bit of structure
depth under each sect* elements?

BTW, I do realize that the column values will need to be properly quoted and
escaped, but that is an issue I have already solved and left out of the XSL to
simplify the explanation of the problem.


Thanks, Andy.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent