docbook-apps

  • 1.  Declaring Namespaces

    Posted 11-19-2008 19:20
    Hello,

    I am trying to do an XML to XML translation. I am using XSLT 1.0 and saxon
    6.5.5.

    Here is my input file:


    <sect1 xmlns="http://docbook.org/ns/docbook" xmlns:xl="
    http://www.w3.org/1999/xlink">
    <sect1 xml:id="class-com.bruxton.sidx.acquisition"
    xreflabel="com.bruxton.sidx.Acquisition">

    <indexterm>
    <primary>Acquisition</primary>
    </indexterm>
    <indexterm>
    <primary>Classes</primary>
    <secondary>Acquisition</secondary>
    </indexterm>
    <para>Responsible for managing the acquisition. Each instance of
    <literal>
    Camera
    </literal> owns one instance of the class. The user of SIDX should
    not create the object. It should be obtained by using getAcquisition
    function of <literal>
    Camera
    </literal> object.</para>
    <sect2>

    <classsynopsis class="class" language="java">

    Here is my XSLT 1.0 file:


    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    version="1.0">

    <xsl:output method="xml" version="1.0" indent="yes"/>


    <xsl:template match="sect1/sect1[@*]">
    <xsl:call-template name="id_sect1"/>
    </xsl:template>



    <xsl:template match="sect2">
    <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
    </xsl:copy>
    </xsl:template>

    The result is untagged, plain text. What am I missing? Any help would be
    greatly appreciated. Thanks!

    Lillian



  • 2.  Re: [docbook-apps] Declaring Namespaces

    Posted 11-19-2008 19:35
    Hi,

    On Mittwoch, 19. November 2008, Lillian Sullam wrote:
    >
    > I am trying to do an XML to XML translation. I am using XSLT 1.0 and
    > saxon 6.5.5.
    >
    > Here is my input file:
    > [... DocBook5 file ...]
    >
    > Here is my XSLT 1.0 file:
    >
    >
    > <xsl:stylesheet
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns="http://docbook.org/ns/docbook"
    ^^^
    Better use a prefix instead of the default namespace:

    xmlns:d="http://docbook.org/ns/docbook"


    > xmlns:xl="http://www.w3.org/1999/xlink"
    > version="1.0">
    >
    > <xsl:output method="xml" version="1.0" indent="yes"/>
    >
    >
    > <xsl:template match="sect1/sect1[@*]">
    > <xsl:call-template name="id_sect1"/>
    > </xsl:template>

    Use the above prefix in all your match attributes:

    <xsl:template match="d:sect1/d:sect1[@*]">

    By the way: The above template will never match. DocBook does not allow to
    insert a sect1 into a sect1. Did you mean sect2 for the second sect1?


    Hope that solves the problem. :)


    Tom


    --
    Thomas Schraitle