I have a XML file in which everything is well structured except for ordered lists. Every list item is tagged as a paragraph <p>, with the enumeration added manually: (1). I want to create a valid HTML list from that source.
Using the xsl:matching-substring method and regular expressions I was able to extract every list item but I can't seem to find a way to add the surrounding <ol> tags.
Here is an example:
XML source:
<Content>
<P>(1) blah</P>
<P>(2) blah</P>
<P>(2) blah</P>
</Content>
What I have so far:
<xsl:variable name="text" select="/Content/*/text()"/>
<xsl:analyze-string select="$text" regex="(\(\d+\))([^(]*)">
<xsl:matching-substring>
<![CDATA[<li>]]><xsl:value-of select="regex-group(2)"/><![CDATA[</li>]]>
</xsl:matching-substring>
</xsl:analyze-string>
Output:
<li>blah</li>
<li>blah</li>
<li>blah</li>
In case you are wondering: output has to be plain text in general, only the contents of the $text variable have to be output in HTML. That's why I am using <![CDATA[]].