I have a XML file which has non standard html elements like so: Note: Paragraphs have been shortend.
<content>
Sacrifice. It's Mass Effect 3's major theme...
<p />
Mass Effect was about time and place; you d...
<p />
Mass Effect 3 is focused more on plot th...
<p />
<img url="me3_img1.jpg">Plenty of games feat...</img>
Like Star Wars, Mass Effect 3 is an inc...
<p />
The reapers aren't your only adver...
<p />
<img url="me3_img2.jpg">If looks could kill..</img>
The series' focus on player choice is as vi...
<p />
This intense narrative is met wi...
<p />
<img url="me3_img3.jpg">The sun is sett...</img>
These are exquis...
</content>
Each will be a gap between the paragraphs. Each image must appear in-between paragraphs where they apear in the content, the must also have a caption, with the content being that between and Note also that the has a url and not a src, so this must change.
My current xslt only copy-of, and css fixes the layout, but img are not displaying because I can't change url to src, aswell as set the caption.
Please help.
Update:
<xsl:for-each select='./review/content/child::*'>
<xsl:value-of select="name()"/>
<xsl:choose>
<xsl:when test="name()='p'">
<p />
</xsl:when>
<xsl:when test="name()='img'">
<div class="reviewImage">
<img>
<xsl:attribute name="src">
<xsl:value-of select="./@url"/>
</xsl:attribute>
</img>
<xsl:value-of select="."/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
It is not outputing any of the text(). The Images and captions are sorted now though.
Solution found:
<xsl:for-each select='./review/content/node()'>
<xsl:choose>
<xsl:when test="name()='p'">
<p />
</xsl:when>
<xsl:when test="name()='img'">
<div class="reviewImage">
<img>
<xsl:attribute name="src">
<xsl:value-of select="./@url"/>
</xsl:attribute>
</img>
<xsl:value-of select="."/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>