docbook-apps

  • 1.  support for xpointer

    Posted 09-14-2014 01:23
    Hello,

    Sorry if the following is slightly off-topic.

    I'm trying to refactor a large docbook document (an API specification)
    into multiple documents, including relevant chunks of content from a
    "meta-model" document into a "language-bindings" document via xinclude /
    xpointer.

    I played a bit with the sample code from
    http://www.sagehill.net/docbookxsl/ModularDoc.html, using xsltproc
    (Using libxml 20901, libxslt 10128 and libexslt 817) on Fedora 20, with
    mixed results. While I got simple cases working, slightly more advanced
    cases led to wrong results, letting me doubt the quality of the
    implementation of xpointer support in xsltproc.

    Can anyone confirm the state of xpointer support in xsltproc, or any
    other Free XSLT processor for that matter ? (For example, what about
    saxon ?) Are there any (free) test suites that I could use to get a
    sense of what is supported and what not ?

    Many thanks,
    Stefan

    --

    ...ich hab' noch einen Koffer in Berlin...




  • 2.  Re: [docbook-apps] support for xpointer

    Posted 09-14-2014 09:10
    On 14.9.2014 3:22, Stefan Seefeld wrote:
    > Can anyone confirm the state of xpointer support in xsltproc, or any
    > other Free XSLT processor for that matter ? (For example, what about
    > saxon ?) Are there any (free) test suites that I could use to get a
    > sense of what is supported and what not ?

    AFAIK only thing which is reliable and works across different
    implementations is referencing node by its ID. Very sad.

    There is XInclude test suite, which has some XPointer tests as well:

    http://dev.w3.org/cvsweb/2001/XInclude-Test-Suite/

    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------




  • 3.  Re: [docbook-apps] support for xpointer

    Posted 09-14-2014 14:35
    On 09/14/2014 05:09 AM, Jirka Kosek wrote:
    > On 14.9.2014 3:22, Stefan Seefeld wrote:
    >> Can anyone confirm the state of xpointer support in xsltproc, or any
    >> other Free XSLT processor for that matter ? (For example, what about
    >> saxon ?) Are there any (free) test suites that I could use to get a
    >> sense of what is supported and what not ?
    > AFAIK only thing which is reliable and works across different
    > implementations is referencing node by its ID. Very sad.

    That's sad indeed. I was trying to fetch a specific subnode of an
    identified element, but couldn't manage to get that working with
    xsltproc (haven't tried with saxon yet), so I was looking for working
    examples.

    (I'm not even sure what the right spelling is to express "second
    listitem within a section with id "demo" " using xpointers. And xsltproc
    typically doesn't even give an error. It simply ignores the entire
    xpointer attribute :-( )

    > There is XInclude test suite, which has some XPointer tests as well:
    >
    > http://dev.w3.org/cvsweb/2001/XInclude-Test-Suite/

    Thanks. These tests all are rather old, and limited as far as I can see.
    Hasn't there been any recent activity on xpointers recently ? What other
    tools for transclusion are people using nowadays ?

    Thanks,
    Stefan

    --

    ...ich hab' noch einen Koffer in Berlin...




  • 4.  Re: [docbook-apps] support for xpointer

    Posted 09-14-2014 18:03
    I have had success using xmllint to access nodes using xpath.

    I can't tell you how well it supports xpath, but I am able to do things like the example below, which turns a chapter into a preface and changes the title.

    <preface>

    <xi:include href="ebook-intro.xml"
    xpointer="xmlns(d=http://docbook.org/ns/docbook)xpointer(/d:chapter/d:info/following-sibling::*))"/>

    </preface>

    I vaguely remember being told that the support for xinclude in xmllint is neither complete nor standard, so I wouldn't expect the markup above to work for any other tool, but xmllint does what I need:-).

    Regarding the question of pulling the second listitem from a section with a particular id, I think the following will do the trick (I don't claim it's the most elegant way to do this, but it works with xmllint):

    <xi:include href="filename.xml"
    xpointer="xmlns(d=http://docbook.org/ns/docbook)xpointer(//d:section[@xml:id='sect-a']//d:listitem[2]))"/>


    Best regards,
    Dick
    -------
    XML Press
    XML for Technical Communicators
    http://xmlpress.net
    hamilton@xmlpress.net



    On Sep 14, 2014, at 7:34, Stefan Seefeld <stefan@seefeld.name> wrote:

    > On 09/14/2014 05:09 AM, Jirka Kosek wrote:
    >> On 14.9.2014 3:22, Stefan Seefeld wrote:
    >>> Can anyone confirm the state of xpointer support in xsltproc, or any
    >>> other Free XSLT processor for that matter ? (For example, what about
    >>> saxon ?) Are there any (free) test suites that I could use to get a
    >>> sense of what is supported and what not ?
    >> AFAIK only thing which is reliable and works across different
    >> implementations is referencing node by its ID. Very sad.
    >
    > That's sad indeed. I was trying to fetch a specific subnode of an
    > identified element, but couldn't manage to get that working with
    > xsltproc (haven't tried with saxon yet), so I was looking for working
    > examples.
    >
    > (I'm not even sure what the right spelling is to express "second
    > listitem within a section with id "demo" " using xpointers. And xsltproc
    > typically doesn't even give an error. It simply ignores the entire
    > xpointer attribute :-( )
    >
    >> There is XInclude test suite, which has some XPointer tests as well:
    >>
    >> http://dev.w3.org/cvsweb/2001/XInclude-Test-Suite/
    >
    > Thanks. These tests all are rather old, and limited as far as I can see.
    > Hasn't there been any recent activity on xpointers recently ? What other
    > tools for transclusion are people using nowadays ?
    >
    > Thanks,
    > Stefan
    >
    > --
    >
    > ...ich hab' noch einen Koffer in Berlin...
    >
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >




  • 5.  Re: [docbook-apps] support for xpointer

    Posted 09-14-2014 20:01
    On 09/14/2014 02:02 PM, Richard Hamilton wrote:
    > Regarding the question of pulling the second listitem from a section with a particular id, I think the following will do the trick (I don't claim it's the most elegant way to do this, but it works with xmllint):
    >
    > <xi:include href="filename.xml"
    > xpointer="xmlns(d=http://docbook.org/ns/docbook)xpointer(//d:section[@xml:id='sect-a']//d:listitem[2]))"/>

    Thanks, that works indeed !
    But the syntax is rather verbose and cumbersome, especially given that I
    want to establish references such as the above for a couple of hundreds
    of definitions in a single (modular) document.
    I'm considering defining my own technique (drawing inspiration from
    http://www.docbook.org/docs/transclusion/transclusion.html), then using
    a two-phase processing with the first doing the transclusion processing
    to generate valid DocBook, then the second to do the actual formatting.

    Thanks for all the help (and the continued work that goes into DocBook's
    evolution),

    Stefan

    --

    ...ich hab' noch einen Koffer in Berlin...




  • 6.  Re: [docbook-apps] support for xpointer

    Posted 09-14-2014 20:37
    Hi Stefan,

    I didn't say it was elegant:-).

    I agree that DocBook transclusion may be the way to go. I need to look into it further for our book process.

    And a multi-stage process works well for us. Maybe it's my long experience with Unix, but I use multi-stage processes all the time. They let you use the right tool for each step in the process and give you intermediate files that you can examine when things go wrong.

    Our current process uses xmllint, xsltproc, saxon (6 and 8), and perl, all stitched together using make (someday I may use ant, but not today:-).

    Dick
    -------
    XML Press
    XML for Technical Communicators
    http://xmlpress.net
    hamilton@xmlpress.net



    On Sep 14, 2014, at 13:01, Stefan Seefeld <stefan@seefeld.name> wrote:

    > On 09/14/2014 02:02 PM, Richard Hamilton wrote:
    >> Regarding the question of pulling the second listitem from a section with a particular id, I think the following will do the trick (I don't claim it's the most elegant way to do this, but it works with xmllint):
    >>
    >> <xi:include href="filename.xml"
    >> xpointer="xmlns(d=http://docbook.org/ns/docbook)xpointer(//d:section[@xml:id='sect-a']//d:listitem[2]))"/>
    >
    > Thanks, that works indeed !
    > But the syntax is rather verbose and cumbersome, especially given that I
    > want to establish references such as the above for a couple of hundreds
    > of definitions in a single (modular) document.
    > I'm considering defining my own technique (drawing inspiration from
    > http://www.docbook.org/docs/transclusion/transclusion.html), then using
    > a two-phase processing with the first doing the transclusion processing
    > to generate valid DocBook, then the second to do the actual formatting.
    >
    > Thanks for all the help (and the continued work that goes into DocBook's
    > evolution),
    >
    > Stefan
    >
    > --
    >
    > ...ich hab' noch einen Koffer in Berlin...
    >




  • 7.  Re: [docbook-apps] support for xpointer

    Posted 09-19-2014 13:54
    On 2014-09-14 16:36, Richard Hamilton wrote:
    > Hi Stefan,
    >
    > I didn't say it was elegant:-).
    >
    > I agree that DocBook transclusion may be the way to go. I need to look into it further for our book process.
    >
    > And a multi-stage process works well for us. Maybe it's my long experience with Unix, but I use multi-stage processes all the time. They let you use the right tool for each step in the process and give you intermediate files that you can examine when things go wrong.

    Right. The disadvantage is that the original document no longer is a
    valid DocBook document, and thus requires RNG customization to make my
    editor happy (not to mention that the transclusion no longer is a
    transparent process).

    Ideally I would like to be able to encode the query in an attribute,
    much as I would have preferred with xpointer, such as

    <listitem my:ref="*[@xml:id='foo']//d:listitem" />

    However, I can't manage to extract the above "ref" into a variable and
    concatenate that into a valid xpath expression inside a custom stylesheet:

    <xsl:template match="*[@my:ref]">
    <xsl:variable name="ref" select="@my:ref" />
    <xsl:variable name=content select="document('dict.xml')//$ref" />
    ...
    </xsl:template>

    It seems I'm misunderstanding something, as no matter how I spell the
    above, I get XPath errors from xsltproc.
    The only thing that seems to work is me injecting individual names into
    an XPath expression, such as

    <xsl:variable name=content
    select="document('dict.xml')//d:section[@xml:id=$ref]//listitem[2]" />

    which however severely limits my flexibility as it supposes a fixed
    structure ("include the second listitem of the identified section"). Am
    I asking too much ?

    Many thanks,
    Stefan

    --

    ...ich hab' noch einen Koffer in Berlin...




  • 8.  Re: [docbook-apps] support for xpointer

    Posted 09-19-2014 14:17
    Hi Stefan,

    On Fri, 19 Sep 2014 09:53:33 -0400
    Stefan Seefeld <stefan@seefeld.name> wrote:

    > [...]
    > Ideally I would like to be able to encode the query in an attribute,
    > much as I would have preferred with xpointer, such as
    >
    > <listitem my:ref="*[@xml:id='foo']//d:listitem" />
    >
    > However, I can't manage to extract the above "ref" into a variable and
    > concatenate that into a valid xpath expression inside a custom
    > stylesheet:
    >
    > <xsl:template match="*[@my:ref]">
    > <xsl:variable name="ref" select="@my:ref" />
    > <xsl:variable name=content select="document('dict.xml')//$ref" />
    > ...
    > </xsl:template>
    >
    > It seems I'm misunderstanding something, as no matter how I spell the
    > above, I get XPath errors from xsltproc.

    Yes, as you try to dynamically evaluate a string as an XPath
    expression. This is not possible with standard XSLT 1.0 and 2.0.

    However, you could look into the dyn:evaluate() extension functions from
    the EXSLT initiative:

    http://exslt.org/dyn/functions/evaluate/index.html

    You may try this, although I haven't tested it:

    <xsl:template match="*[@my:ref]" xmlns:dyn="http://exslt.org/dynamic">
    <xsl:variable name="ref" select="dyn:evaluate(@my:ref)" />
    <xsl:variable name=content select="document('dict.xml')//$ref" />
    ...
    </xsl:template>

    Unfortunately, very few XSLT 1.0 processors implement dyn:evaluate().
    It works in xsltproc, but it's unlikely it will work for Saxon.


    > [...]


    --
    Gruß/Regards,
    Thomas Schraitle



  • 9.  Re: [docbook-apps] support for xpointer

    Posted 09-19-2014 14:41
    Hi Thomas,

    On 2014-09-19 10:17, Thomas Schraitle wrote:
    > Hi Stefan,
    >
    > On Fri, 19 Sep 2014 09:53:33 -0400
    > Stefan Seefeld <stefan@seefeld.name> wrote:
    >
    >> [...]
    >> Ideally I would like to be able to encode the query in an attribute,
    >> much as I would have preferred with xpointer, such as
    >>
    >> <listitem my:ref="*[@xml:id='foo']//d:listitem" />
    >>
    >> However, I can't manage to extract the above "ref" into a variable and
    >> concatenate that into a valid xpath expression inside a custom
    >> stylesheet:
    >>
    >> <xsl:template match="*[@my:ref]">
    >> <xsl:variable name="ref" select="@my:ref" />
    >> <xsl:variable name=content select="document('dict.xml')//$ref" />
    >> ...
    >> </xsl:template>
    >>
    >> It seems I'm misunderstanding something, as no matter how I spell the
    >> above, I get XPath errors from xsltproc.
    > Yes, as you try to dynamically evaluate a string as an XPath
    > expression. This is not possible with standard XSLT 1.0 and 2.0.
    >
    > However, you could look into the dyn:evaluate() extension functions from
    > the EXSLT initiative:
    >
    > http://exslt.org/dyn/functions/evaluate/index.html
    >
    > You may try this, although I haven't tested it:
    >
    > <xsl:template match="*[@my:ref]" xmlns:dyn="http://exslt.org/dynamic">
    > <xsl:variable name="ref" select="dyn:evaluate(@my:ref)" />
    > <xsl:variable name=content select="document('dict.xml')//$ref" />
    > ...
    > </xsl:template>

    Great, it seems dyn:evaluate() is exactly what I'm looking for. Note
    that I had to rephrase the above a little, as the way you wrote it
    wouldn't work, since the evaluation of the (dynamic) xpath only makes
    sense in the context of the "doct.xml" document, and thus can't be done
    outside it.

    But with that little adjustment I now get the expected result. It's
    still not very pretty, but a huge step in the right direction.

    > Unfortunately, very few XSLT 1.0 processors implement dyn:evaluate().
    > It works in xsltproc, but it's unlikely it will work for Saxon.

    Yeah, tools support has always been a great bottleneck with XML
    processing. :-(

    Many thanks,
    Stefan

    --

    ...ich hab' noch einen Koffer in Berlin...




  • 10.  Re: [docbook-apps] support for xpointer

    Posted 09-16-2014 08:21
    On Sun, 14 Sep 2014 16:01:27 -0400
    Stefan Seefeld <stefan@seefeld.name> wrote:

    > On 09/14/2014 02:02 PM, Richard Hamilton wrote:
    > > Regarding the question of pulling the second listitem from a
    > > section with a particular id, I think the following will do the
    > > trick (I don't claim it's the most elegant way to do this, but it
    > > works with xmllint):
    > >
    > > <xi:include href="filename.xml"
    > > xpointer="xmlns(d=http://docbook.org/ns/docbook)xpointer(//d:section[@xml:id='sect-a']//d:listitem[2]))"/>
    >
    > Thanks, that works indeed !
    > But the syntax is rather verbose and cumbersome, especially given
    > that I want to establish references such as the above for a couple of
    > hundreds of definitions in a single (modular) document.
    > I'm considering defining my own technique (drawing inspiration from
    > http://www.docbook.org/docs/transclusion/transclusion.html), then
    > using a two-phase processing with the first doing the transclusion
    > processing to generate valid DocBook, then the second to do the
    > actual formatting.
    >
    > Thanks for all the help (and the continued work that goes into
    > DocBook's evolution),
    >
    > Stefan

    If the cmd line is any help, have you looked at http://blog.xmlsh.org/ ?

    regards


    --

    regards

    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    http://www.dpawson.co.uk