views:

55

answers:

2

I recently changed a couple of my .xml files from docbook to dita. The conversion went ok, but there are some unwanted artifacts. The one I'm stumped on is that .dita does not recongnize the <para> tag from docbook, and replaces it with <p>. Which you'd think would be fine, but this causes the XML to show items in and ordered list as being on the next line, i.e:

1
 item One
2
 item Two

instead of:

1 item One
2 item Two

so how do i change this:

<section>
<title>Cool Stuff</title>
<orderedlist>
  <listitem>
    <para>ItemOne</para>
  </listitem>

  <listitem>
    <para>ItemTwo</para>
  </listitem>
</orderedlist>

to this:

<section>
<title>Cool Stuff</title>
<orderedlist>
  <listitem>
    ItemOne
  </listitem>

  <listitem>
    ItemTwo
  </listitem>
</orderedlist>

I'm sorry, I should have been more clear with the question. I need to remove all tags from the doument which are at varying levels of depth, but always follow the (local) tree listitem/para . I'm a bit new to this, but could I could just be doing it wrong by tacking it on to my docbook2dita transformation. Can it be in that place?

+2  A: 

You can process the dita files with an XSLT that filters out the <para> nodes:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  <xsl:output method="xml" indent="yes"/>

  <!-- copy elements and attributes -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- replace para nodes within an orderedlist with their content -->     
  <xsl:template match ="orderedlist/listitem/para">
    <xsl:value-of select="."/>
  </xsl:template>

</xsl:stylesheet>
0xA3
I'm sorry, I should have been more clear with the question. I need to remove all <para> tags from the doument which are at varying levels of depth, but always follow the (local) tree orderedlist/listitem/para . I'm a bit new to this, but could I could just be doing it wrong by tacking it on to my docbook2dita transformation. Can it be in that place?
Ace
+3  A: 

I would use this stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match ="listitem/para">
        <xsl:apply-templates/>
    </xsl:template>
</xsl:stylesheet>

Note: Overwrite identity rule. listitem/para are bypassed (this preserves mixed content)

Alejandro