The number of paragraphs p is not regular. I don't get this xslt to work that it takes all of the p nodes into consideration. Instead it only takes the first. Furthermore it "mixes them up" with the i nodes.
This is the xml
<article> <texte> <notes>-</notes> <content> <title>T 1</title> <argument>Arg 1</argument> <p>Paragraph 1.1</p> <p>Paragraph 1.2</p> <p>Paragraph <i>1.3</i></p> <short-author>FB</short-author> </content> <notes>-</notes> <content> <title>T2</title> <p>Paragraph 2.1</p> <short-author>JD</short-author> </content> <notes>-</notes> <content> <title>T3</title> <argument>Arg 3</argument> <p>Paragraph 3.1</p> <short-author>NC</short-author> </content> </texte> </article> </doc> This is the xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <article><xsl:text> </xsl:text> <xsl:for-each select="doc/article/texte/content"> <xsl:for-each select="preceding-sibling::notes[1]"> <notes><xsl:value-of select="." /></notes> </xsl:for-each><xsl:text> </xsl:text> <title><xsl:value-of select="title" /></title> <xsl:text> </xsl:text> <argument><xsl:value-of select="argument" /></argument> <xsl:text> </xsl:text> <p><xsl:value-of select="p" /> <xsl:for-each select="child::*[i]"> <i><xsl:value-of select="i" /></i> </xsl:for-each> </p> <xsl:text> </xsl:text> <short-author><xsl:value-of select="short-author" /></short-author> <xsl:text> </xsl:text> </xsl:for-each> </article> </xsl:template> </xsl:stylesheet> And this is the result
<?xml version="1.0"?> <article> <notes>-</notes> <title>T 1</title> <argument>Arg 1</argument> <p>Paragraph 1.1<i>1.3</i></p> <short-author>FB</short-author> <notes>-</notes> <title>T2</title> <argument/> <p>Paragraph 2.1</p> <short-author>JD</short-author> <notes>-</notes> <title>T3</title> <argument>Arg 3</argument> <p>Paragraph 3.1</p> <short-author>NC</short-author> </article> Thank you very much!
No comments:
Post a Comment