Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have the following XML for a news

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I have the following XML for a news story. It is designed to re-format some XML There are multiple images associated with it.

<content>
<story>
<headline>a headline</headline>
<image></image>
<image></image>
<image></image>
<image></image>
</story>
</content>

I want to select the values of the image tags with XSL

This is what I have so far.

<xsl:for-each select=&quot;content/story&quot;

<story>

<headline><xsl:value-of select=&quot;headline&quot; /></headline>


<xsl:for-each select=&quot;image&quot;>
<image><xsl:value-of select=&quot;image&quot; /></image>
</xsl:for-each>

</story>
</xsl:for-each>


However it doesn't seem to select the image values so that it produces:

<headline>a headline</headline>
<image></image>
<image></image>
<image></image>
<image></image>


What am I doing wrong?
 
question: why are you recreating the xml document with the xsl?

the information you are trying to produce is identical to the xml you are reading. is there a reason for this?

apart from that, the xsl you provide (apart from missing a > at the end of your <for-each> tag) produces what you are expecting... heres my xsl:

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; <xsl:template match=&quot;/&quot;>
<xsl:for-each select=&quot;content/story&quot;>
<story>
<headline>
<xsl:value-of select=&quot;headline&quot; />
</headline>
<xsl:for-each select=&quot;image&quot;>
<image>
<xsl:value-of select=&quot;image&quot; />
</image>
</xsl:for-each>
</story>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top