Re: XSL Newbie but a really annoying problem



danmat46@xxxxxxxxxxxxxx wrote:
Morning all,
Just started out with XSL.
Now working on my first example I have the following XML structure

<topLevel>
<repeatLevel name="hello" type="hello">
<![CDATA[sometext in here]]>
</repeatLevel>
<repeatLevel name="hello2" type="hello2">
<![CDATA[more text in here]]>
</repeatLevel>
</topLevel>

Now developing the XSL is going fine, I have an html table with three
columns and been able to output the name and type but I cannot get the
CDATA's text in the third column.

Is this possible?

Sure, why not? In the XSLT/XPath data model there are no CDATA sections anyway, the repeatLevel elements simply have a string value so you can do e.g.
<xsl:template match="repeatLevel">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="@type"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:template>

Or with additonal templates you do e.g.

<xsl:template match="repeatLevel">
<tr>
<xsl:apply-templates select="@* | node()"/>
</tr>
</xsl:template>

<xsl:template match="repeatLevel/@* | repeatLevel/text()">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/
.



Relevant Pages

  • XSL Newbie but a really annoying problem
    ... Just started out with XSL. ... Now working on my first example I have the following XML structure ... CDATA's text in the third column. ...
    (comp.text.xml)
  • Re: Maybe its a bug
    ... First of all, i don't revise the xml structure by coding, the ... Using an XSL transformation is ... In my opinion, it's not the fault of XSL, but ADO. ... structure can be converted to Recordset, ...
    (microsoft.public.data.ado)
  • Re: XML to XML using XSL
    ... I need to change values in this file using XSL and ... produce same XML structure as output. ... 'ABC', I suppose. ... Pavel Lepin ...
    (comp.text.xml)
  • Text replacement
    ... I have a question concerning XSL and text replacement. ... following simple XML structure: ... Now I want to transform this to: ...
    (comp.text.xml)