If you're using Saxon you could use saxon:serialize(). Or you could use Evan
Lenz's serializer implemented in XSLT:
http://www.stylusstudio.com/xsllist/200105/post61330.html
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Houghton,Andrew [mailto:houghtoa(_at_)oclc(_dot_)org]
Sent: 03 September 2006 06:18
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Converting a node tree to a textual representation
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,' ')"/>
</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.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--