XSL Newbie but a really annoying problem

D

danmat46

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?

And no unfortunatly I cannot change the XML format to add the CDATA as
an attribute.

Any help welcomed!

Thank you
 
P

Pavel Lepin

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?

Yes, it is possible.
 
M

Martin Honnen

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top