Hi Cameron,

I put the xml mailing list on CC as you might find further answers there.
Find my answer inlined:

Cameron Zemek wrote:
I am converting snippets of XHTML to be inserted into Open Document files. For example,

<ul>
  <li>item1
  <ul>
    <li>subitem1</li>
    <li>subitem2</li>
    <li>subitem3</li>
  </ul></li>
  <li>item2</li>
  <li>item3</li>
  <li>multi<br>line</li>
</ul>

I currently got a XSL stylesheet to change this to Open Document XML, but have hit a wall with wrapping text in text tags. The correct conversion for the above should be:

<text:list>
  <text:list-item><text:p>item1</text:p>
    <text:list>
      <text:list-item><text:p>subitem1</text:p></text:list-item>
      <text:list-item><text:p>subitem2</text:p></text:list-item>
      <text:list-item><text:p>subitem3</text:p></text:list-item>
    </text:list>
  </text:list-item>
  <text:list-item><text:p>item2</text:p>
  <text:list-item><text:p>item3</text:p>
  <text:list-item>
    <text:p>multi</text:p><text:p>line</text:p>
  </text:list-item>
</text:list>

What rule can I use to add the <text:p> tags? I've tried:
<xsl:template match="li/text()">
    <text:p><xsl:value-of select="text()"></text:p>
</xsl:template>

But end up with the closing </text:p> in the wrong palce. Eg. <text:p>item1<!--sub list here--></text:p>

Any ideas?


A simple approach for the above demands could be the following:

 <xsl:template match="ol | ul" mode="list">
        <text:list>
                <xsl:apply-templates mode="list"/>
        </text:list>
 </xsl:template>

 <xsl:template match="li" mode="list">
        <text:list-item>
                <xsl:apply-templates mode="list"/>
        </text:list-item>
 </xsl:template>

 <xsl:template match="text()" mode="list">
     <text:p><xsl:value-of select="text()"></text:p>
 </xsl:template>


But be aware that <li> might usually have more nodes than text as
DTD of XHTML strict states:
<!ELEMENT li %Flow;>
Aside of this, you haven't distinguished between unordered and ordered
lists, yet.

You might want to take a look into the XHTML export of
StarOffice7pp5/OO.o1.15 or StarOffice8/OO.o2.0RC
You will find some hints in share/xslt/export/xhtml/body.xsl, although
it still uses the earlier OpenOffice.org XML.

Svante

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to