A
aamcfarland
Hi,
I have an XML document that looks like this:
<srcdoc>
<para>Paragraph</para>
<para>Paragraph with cross-ref <xref/> and ordered list.
<olist>
<item>First item</item>
</olist>
Followed by more text.
</para>
</srcdoc>
and I want to transform it into this:
<doc>
<p>Paragraph</p>
<pParagraph with cross-ref and ordered list</p>
<ol>
<li>First item</li>
</ol>
<p>Followed by more text</p>
</doc>
This is mostly a trivial transform. I can almost do it with this XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xslutput omit-xml-declaration="yes"/>
<xsl:template match="/">
<doc>
<xsl:apply-templates/>
</doc>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="olist">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="item">
<li>
<xsl:apply-templates />
</li>
</xsl:template>
</xsl:stylesheet>
But this gives me the following output:
<doc>
<p>Paragraph</p>
<p>Paragraph with cross-ref and ordered list.
<ol>
<li>First item</li>
</ol>
Followed by more text.
</p>
</doc>
That is the <ol/> is a child of the <p/> rather than a sibling.
I know the standard DocBook to HTML does this, but I just can't work
out how it does it.
I have an XML document that looks like this:
<srcdoc>
<para>Paragraph</para>
<para>Paragraph with cross-ref <xref/> and ordered list.
<olist>
<item>First item</item>
</olist>
Followed by more text.
</para>
</srcdoc>
and I want to transform it into this:
<doc>
<p>Paragraph</p>
<pParagraph with cross-ref and ordered list</p>
<ol>
<li>First item</li>
</ol>
<p>Followed by more text</p>
</doc>
This is mostly a trivial transform. I can almost do it with this XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xslutput omit-xml-declaration="yes"/>
<xsl:template match="/">
<doc>
<xsl:apply-templates/>
</doc>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="olist">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="item">
<li>
<xsl:apply-templates />
</li>
</xsl:template>
</xsl:stylesheet>
But this gives me the following output:
<doc>
<p>Paragraph</p>
<p>Paragraph with cross-ref and ordered list.
<ol>
<li>First item</li>
</ol>
Followed by more text.
</p>
</doc>
That is the <ol/> is a child of the <p/> rather than a sibling.
I know the standard DocBook to HTML does this, but I just can't work
out how it does it.