docbook-apps

Expand all | Collapse all

Use of xincludes vs. entities

  • 1.  Use of xincludes vs. entities

    Posted 09-25-2010 15:25
    Hi All,

    As I understand it, the xincludes feature provides a number of advantages
    over use of entities, but are there some situations where entities are still
    relevant and recommended?

    For example, I'm considering the use of click-paths for guimenu > guisubmenu
    chains. In the past, we have used an entity file to house all of the
    guimenu click-paths for our documentation. If the guimenu click-path
    changed, we would just update it in our entities file, and it would be
    updated throughout the documentation. It seems that using xinclude +
    xpointer to perform the same feature would be overkill for in performing the
    same task. Similarly, in the past we have used entities to handle updates to
    version numbering, and it seems that xinclude + xpointer would be overkill
    there, as well.

    Much of how I've seen xinclude being used seems to be relevant for including
    entire chapters or otherwise large chunks of text, and I do see the
    relevance there. Is xinclude helpful and manageable for smaller textual
    insertions, too, or are entities still a reasonable way to go for these
    types of uses?

    Thanks for your help,

    Jim

    P.S. I do understand that DocBook version 5 schemas do not support entity
    declarations in the schema, and that I'd have to reference the entities file
    via the doctype declaration.



  • 2.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-25-2010 20:10
    Hi Jim,

    I say pick the right tool for the job. I think that the two cases you
    outline above are completely reasonable uses for entities. I'm also a
    bit sheepish about using XInclude with XPointer because of the
    differing levels of support for XPointer in different XSL processors.
    I don't think it's Bad with a captial "B" to use entities in places
    where they are a simple, elegant solution.

    Another way to look at it... While editing, a lot of the XInclude junk
    doesn't seem helpful for a small bit of text replacement:
    <para>The ball is &product_color;.</para>
    <para>The ball is <xi:include href="product_info.xml" xpointer="color"/>.</para>

    I think product_info.xml is just going to be a weird file to maintain,
    too, but that could be personal preference.

    However, if it were a file, xi:include provides valuable information:
    <para>See the following table: &uh_what_file;</para>
    <para>See the following table: <xi:include
    href="../tables/product_table.xml"></para>


    [ I am going to rant slightly off-topic now, but you might find some
    of this interesting and related to your question ]

    I am in a situation right now where I have a very large base of
    existing DocBook material that uses entities extensively. I would like
    to use XPointer for including chunks of text, but I run into all sorts
    of problems when those chunks of text themselves contain entities.

    Consider two books: Book1 and Book2. Book1 defines &foo; as "1" and
    Book2 defines &foo; as "2". I have a file "inc.xml" that's included in
    each book via entities. It has the content: "<para>My number is
    &foo;</para>". It works great. When I view either book in an editor,
    the entity resolves nicely to 1 in Book1 and 2 in Book2.
    Unfortunately, most editors don't allow me to edit the contents of
    "inc.xml", or as soon as they do, &foo; doesn't resolve because it's
    not aware of the parent book that defines it because it's in another
    file.

    Now I change to XInclude. If I simply add a DOCTYPE tag to "inc.xml"
    and include it, &foo; won't resolve at all, because it needs to be
    declared inside "inc.xml". But this file is included by two books
    which would each define the entity differently. What do I do?

    To solve the general case, somebody might tell me that I could define
    &foo; in two different entity files, then create two XML catalogs, one
    for use with each book, that define the same public identifier for
    each respective entity file. I would then use the public identifier
    to declare the entity file in the subset of "inc.xml" and
    conditionally specify one or the other catalog when building each
    book. That's an awful lot of infrastructure, not to mention that I'm
    going to be hard-pressed to find an editor which could elegantly
    handle the catalog situation.

    Somebody else might respond: but clearly there's some ill-conceived
    organization here. Why aren't you using profiling to get the "1" and
    "2"? Surely then, you could define a couple profiled phrases for
    &foo;, then specify the profile when making the book. Well, consider
    what might happen if I had 15 books that each required a unique
    definition? Now every time that entity is used and I'm editing a book,
    I've got to look at a massive chunk of profiled phrases. Still, I'm
    considering this to be the only reasonable route to take; if you name
    your entities well enough you can hide their text values when editing
    material in a nice full-featured editor.

    -Sam

    On Sat, Sep 25, 2010 at 8:25 AM, Jim Campbell <jwcampbell@gmail.com> wrote:
    > Hi All,
    >
    > As I understand it, the xincludes feature provides a number of advantages
    > over use of entities, but are there some situations where entities are still
    > relevant and recommended?
    >
    > For example, I'm considering the use of click-paths for guimenu > guisubmenu
    > chains.  In the past, we have used an entity file to house all of the
    > guimenu click-paths for our documentation.  If the guimenu click-path
    > changed, we would just update it in our entities file, and it would be
    > updated throughout the documentation.  It seems that using xinclude +
    > xpointer to perform the same feature would be overkill for in performing the
    > same task. Similarly, in the past we have used entities to handle updates to
    > version numbering, and it seems that xinclude + xpointer would be overkill
    > there, as well.
    >
    > Much of how I've seen xinclude being used seems to be relevant for including
    > entire chapters or otherwise large chunks of text, and I do see the
    > relevance there.  Is xinclude helpful and manageable for smaller textual
    > insertions, too, or are entities still a reasonable way to go for these
    > types of uses?
    >
    > Thanks for your help,
    >
    > Jim
    >
    > P.S.  I do understand that DocBook version 5 schemas do not support entity
    > declarations in the schema, and that I'd have to reference the entities file
    > via the doctype declaration.
    >



  • 3.  RE: [docbook-apps] Use of xincludes vs. entities

    Posted 09-25-2010 20:26
    Hi Sam and Jim,
    You might be interested in Jirka's proposal for transclusions in DocBook. It notes the problems with xincludes for the very use case you bring up:

    http://lists.oasis-open.org/archives/docbook-tc/201007/msg00041.html

    David




  • 4.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 12:10
    Sorry for mailing so much on this topic, but thanks for the link. The
    information here is great to see, but I'm curious about the current
    status of any work related to this proposal. My situation is difficult
    because I'm sitting on a huge amount of material and don't want to
    pull the trigger upgrading it until I'm certain I have good support
    going forward from editors, parsers, stylesheets, etc. For now, I
    wait.

    -Sam

    On Sat, Sep 25, 2010 at 1:25 PM, Cramer, David W (David)
    <dcramer@motive.com> wrote:
    > Hi Sam and Jim,
    > You might be interested in Jirka's proposal for transclusions in DocBook. It notes the problems with xincludes for the very use case you bring up:
    >
    > http://lists.oasis-open.org/archives/docbook-tc/201007/msg00041.html
    >
    > David
    >
    >


  • 5.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 14:55
    Also see Bob Stayton's summary of using xincludes in
    http://www.sagehill.net/docbookxsl/DuplicateIDs.html.
    I've successfully implemented xincludes in place of entity refs, but it
    was tricky, along the lines that Sam describes.

    That's why I sat up when David mentioned Jirka's transclusion proposal.
    I sure hope it's adopted by the DocBook committee. I'm not much of a
    DITA fan, but resurrecting transclusions is one thing I do like about
    it. DITA conrefs are almost as verbose as xincludes, but they do avoid
    duplicate ids.

    On 09/26/2010 08:10 AM, Sam Fischmann wrote:
    > Sorry for mailing so much on this topic, but thanks for the link. The
    > information here is great to see, but I'm curious about the current
    > status of any work related to this proposal. My situation is difficult
    > because I'm sitting on a huge amount of material and don't want to
    > pull the trigger upgrading it until I'm certain I have good support
    > going forward from editors, parsers, stylesheets, etc. For now, I
    > wait.
    >
    > -Sam
    >
    > On Sat, Sep 25, 2010 at 1:25 PM, Cramer, David W (David)
    > <dcramer@motive.com> wrote:
    >> Hi Sam and Jim,
    >> You might be interested in Jirka's proposal for transclusions in DocBook. It notes the problems with xincludes for the very use case you bring up:
    >>
    >> http://lists.oasis-open.org/archives/docbook-tc/201007/msg00041.html
    >>
    >> David
    >>
    >>


  • 6.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 19:29
    A quick contribution.
    Use Xinclude for large amounts of text, entities for the small stuff.
    One thing I have found useful is using entities to build a skeleton
    index as writing progresses, put all the primary index stuff into the
    entity.
    Ron

    On 9/26/10 9:55 AM, Denis Bradford wrote:
    > Also see Bob Stayton's summary of using xincludes in
    > http://www.sagehill.net/docbookxsl/DuplicateIDs.html.
    > I've successfully implemented xincludes in place of entity refs, but it
    > was tricky, along the lines that Sam describes.
    >
    > That's why I sat up when David mentioned Jirka's transclusion proposal.
    > I sure hope it's adopted by the DocBook committee. I'm not much of a
    > DITA fan, but resurrecting transclusions is one thing I do like about
    > it. DITA conrefs are almost as verbose as xincludes, but they do avoid
    > duplicate ids.
    >
    > On 09/26/2010 08:10 AM, Sam Fischmann wrote:
    >> Sorry for mailing so much on this topic, but thanks for the link. The
    >> information here is great to see, but I'm curious about the current
    >> status of any work related to this proposal. My situation is difficult
    >> because I'm sitting on a huge amount of material and don't want to
    >> pull the trigger upgrading it until I'm certain I have good support
    >> going forward from editors, parsers, stylesheets, etc. For now, I
    >> wait.
    >>
    >> -Sam
    >>
    >> On Sat, Sep 25, 2010 at 1:25 PM, Cramer, David W (David)
    >> <dcramer@motive.com> wrote:
    >>> Hi Sam and Jim,
    >>> You might be interested in Jirka's proposal for transclusions in
    >>> DocBook. It notes the problems with xincludes for the very use case
    >>> you bring up:
    >>>
    >>> http://lists.oasis-open.org/archives/docbook-tc/201007/msg00041.html
    >>>
    >>> David
    >>>
    >>>


  • 7.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 19:37
    Sam Fischmann wrote:
    > Sorry for mailing so much on this topic, but thanks for the link. The
    > information here is great to see, but I'm curious about the current
    > status of any work related to this proposal.

    It is work in progress which can be thrown away in any point or changed
    dramatically. However user feedback is more then welcome in driving
    further development of transclusion proposal and in deciding whether and
    how add DocBook specific transclusion support.

    --
    ------------------------------------------------------------------
    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 member
    ------------------------------------------------------------------




  • 8.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-27-2010 12:10
    I agree with Ron's simple summary: use XInclude for large chunks of
    text and entities for small. The basic problem is that there's no
    elegant way to change bits of the XIncluded text based on the context
    of its inclusion:

    * XML files + multiple catalog sets are awkward and not supported well
    in editors; you basically have to configure the editor each time you
    open a book.

    * Profiling + entities is sometimes inappropriate and forces you to
    group variables by name instead of the context in which they are used,
    which causes maintenance problems.

    Jirka, your proposal is valuable because it would allow me to define
    small text variables for each of several contexts and store them in
    separate definition files. I could then use profiling to conditionally
    include definition files at the top level of a book and not have to
    look at miles of logical cruft every time something is wrong with a
    text variable in my documentation. It does not require multiple
    catalog sets, would be easy for editors to support, and unlike pure
    entity-based inclusion, there's an elegant system for overrides. The
    only unknown here for me is how validation would work. I can see
    myself putting definitionfile tags at the top of every single file via
    a global entity so that XIncluded files validate correctly, but that's
    inelegant again.

    Hope these thoughts are informative or helpful...

    -Sam

    On Sun, Sep 26, 2010 at 12:37 PM, Jirka Kosek <jirka@kosek.cz> wrote:
    > Sam Fischmann wrote:
    >> Sorry for mailing so much on this topic, but thanks for the link. The
    >> information here is great to see, but I'm curious about the current
    >> status of any work related to this proposal.
    >
    > It is work in progress which can be thrown away in any point or changed
    > dramatically. However user feedback is more then welcome in driving
    > further development of transclusion proposal and in deciding whether and
    > how add DocBook specific transclusion support.
    >
    > --
    > ------------------------------------------------------------------
    >  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 member
    > ------------------------------------------------------------------
    >
    >



  • 9.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-27-2010 13:15
    My biggest problem with Xinclude is the duplicate ID if a piece of text
    is included twice etc. Would it be possible to reset an ID of an
    Xincluded test on the Xinclude statement with an attribute, e.g.

    <xi:include href="venn.xml" ***newid="qwerty"***
    xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:fallback><para><emphasis> MISSING INCLUDE FILE - venn.xml
    </emphasis></para></xi:fallback>
    </xi:include>

    Would this be a major enhancement? Is it a reasonable suggestion?

    On the indexing comment, I use things like:
    '<indexterm><primary>Alferes-Mór</primary></indexterm>Alferes-Mór'>

    in a file of entities. This does generate a first, crude pass at an
    index. It also avoids continual re-typing of things like ó

    Ron

    On 9/27/10 7:09 AM, Sam Fischmann wrote:
    > I agree with Ron's simple summary: use XInclude for large chunks of
    > text and entities for small. The basic problem is that there's no
    > elegant way to change bits of the XIncluded text based on the context
    > of its inclusion:
    >
    > * XML files + multiple catalog sets are awkward and not supported well
    > in editors; you basically have to configure the editor each time you
    > open a book.
    >
    > * Profiling + entities is sometimes inappropriate and forces you to
    > group variables by name instead of the context in which they are used,
    > which causes maintenance problems.
    >
    > Jirka, your proposal is valuable because it would allow me to define
    > small text variables for each of several contexts and store them in
    > separate definition files. I could then use profiling to conditionally
    > include definition files at the top level of a book and not have to
    > look at miles of logical cruft every time something is wrong with a
    > text variable in my documentation. It does not require multiple
    > catalog sets, would be easy for editors to support, and unlike pure
    > entity-based inclusion, there's an elegant system for overrides. The
    > only unknown here for me is how validation would work. I can see
    > myself putting definitionfile tags at the top of every single file via
    > a global entity so that XIncluded files validate correctly, but that's
    > inelegant again.
    >
    > Hope these thoughts are informative or helpful...
    >
    > -Sam
    >
    > On Sun, Sep 26, 2010 at 12:37 PM, Jirka Kosek<jirka@kosek.cz> wrote:
    >> Sam Fischmann wrote:
    >>> Sorry for mailing so much on this topic, but thanks for the link. The
    >>> information here is great to see, but I'm curious about the current
    >>> status of any work related to this proposal.
    >>
    >> It is work in progress which can be thrown away in any point or changed
    >> dramatically. However user feedback is more then welcome in driving
    >> further development of transclusion proposal and in deciding whether and
    >> how add DocBook specific transclusion support.
    >>
    >> --
    >> ------------------------------------------------------------------
    >> 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 member
    >> ------------------------------------------------------------------
    >>
    >>
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >
    >
    >

    --
    Ron Catterall Ph.D. D.Sc.
    ron@catterall.net
    http://catterall.net




  • 10.  RE: [docbook-apps] Use of xincludes vs. entities

    Posted 09-27-2010 16:18
    Ron Catterall [mailto:ron@catterall.net] wrote:

    > My biggest problem with Xinclude is the duplicate ID if a piece of text
    > is included twice etc. Would it be possible to reset an ID of an
    > Xincluded test on the Xinclude statement with an attribute, e.g.
    >
    > <xi:include href="venn.xml" ***newid="qwerty"***
    > xmlns:xi="http://www.w3.org/2001/XInclude">
    > <xi:fallback><para><emphasis> MISSING INCLUDE FILE - venn.xml
    > </emphasis></para></xi:fallback>
    > </xi:include>
    >
    > Would this be a major enhancement? Is it a reasonable suggestion?


    XInclude is not part of DocBook. I think you'd need to go through the W3C to propose enhancements to it. That said, your solution only solves part of the problem, I think. What about IDs on elements that are inside the main XIncluded element? And what about nested XIncludes?

    Personally I haven't had a lot of issues with XIncludes and IDs. Usually if I give something an ID, it's because it's unique, and therefore I'm unlikely to include it twice in the same document.


    *************************
    Rob Cavicchio
    Principal Technical Writer & Information Architect
    EMC Captiva
    Information Intelligence Group
    EMC Corporation
    3721 Valley Centre Drive, Ste 200
    San Diego, CA 92130

    P: (858) 320-1208
    F: (858) 320-1010
    E: rob.cavicchio@emc.com

    The opinions expressed here are my personal opinions. Content published here is not read or approved in advance by EMC and does not necessarily reflect the views and opinions of EMC.




  • 11.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-27-2010 17:10
    > XInclude is not part of DocBook. I think you'd need to go through the W3C to propose enhancements to it. That
    > said, your solution only solves part of the problem, I think. What about IDs on elements that are inside
    > the main XIncluded element? And what about nested XIncludes?

    Hm... For that, you could suggest a prefix attribute, where said
    prefix is prepended to all ids in the XIncluded document. This prefix
    would compound with nesting. On the other hand, you could dig yourself
    into a huge, terrible hole using that technique.

    > Personally I haven't had a lot of issues with XIncludes and IDs. Usually if I give something an ID, it's because
    > it's unique, and therefore I'm unlikely to include it twice in the same document.

    Usually that's true for larger cunks, but it wouldn't be in the case
    when using XPointer to include small texty bits instead of entities
    (say, for example, the menu paths Jim stated in the email at the top
    of this thread). Those elements will need an ID just so you can grab
    them, and they will be included in the document multiple times. I
    guess that's moot if we generally agree that's not a good use case for
    XInclude, though.

    -Sam



  • 12.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 10-05-2010 07:27
    Sam Fischmann wrote:

    > Hm... For that, you could suggest a prefix attribute, where said
    > prefix is prepended to all ids in the XIncluded document. This prefix
    > would compound with nesting. On the other hand, you could dig yourself
    > into a huge, terrible hole using that technique.

    My experience shows that it is much easier to prepend only one prefix,
    not to compound them. Prepended prefix should be unique to element
    responsible for transclusion (ref in transclusions, xi:include in
    XInclude). With XInclude there is a problem that you will have to write
    custom XInclude processor and disable default XInclude processing which
    is already available in many existing tools.

    --
    ------------------------------------------------------------------
    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 member
    ------------------------------------------------------------------




  • 13.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 10-05-2010 07:22
    Sam Fischmann wrote:

    > Jirka, your proposal is valuable because it would allow me to define
    > small text variables for each of several contexts and store them in
    > separate definition files. I could then use profiling to conditionally
    > include definition files at the top level of a book and not have to
    > look at miles of logical cruft every time something is wrong with a
    > text variable in my documentation. It does not require multiple
    > catalog sets, would be easy for editors to support, and unlike pure
    > entity-based inclusion, there's an elegant system for overrides. The
    > only unknown here for me is how validation would work. I can see
    > myself putting definitionfile tags at the top of every single file via
    > a global entity so that XIncluded files validate correctly, but that's
    > inelegant again.

    The idea is to extend DocBook with these new transclusion elements. Of
    course if you are creating modular documents in any way it is wise to
    validate result document after all transclusions are resolved.

    --
    ------------------------------------------------------------------
    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 member
    ------------------------------------------------------------------




  • 14.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 07:31
    On Sat, 25 Sep 2010 13:09:45 -0700
    Sam Fischmann <sam.fischmann@gmail.com> wrote:

    > Hi Jim,
    >
    > I say pick the right tool for the job. I think that the two cases you
    > outline above are completely reasonable uses for entities. I'm also a
    > bit sheepish about using XInclude with XPointer because of the
    > differing levels of support for XPointer in different XSL processors.

    AFAIK xInclude processing isn't a job for an application such
    as an XSL engine or an editor, it is the job of the XML parser.




    --

    regards

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



  • 15.  Re: [docbook-apps] Use of xincludes vs. entities

    Posted 09-26-2010 11:51
    Ah, sorry for that. Even so, depending on the parser you're using,
    there are multiple XPointer schemes that it could support and you have
    to pick one that you'll standardize over. Xerces, for example, only
    supports the element() scheme. If you need to use other tools to parse
    your documents, better hope they support that scheme as well.

    -Sam

    On Sun, Sep 26, 2010 at 12:30 AM, Dave Pawson <davep@dpawson.co.uk> wrote:
    > On Sat, 25 Sep 2010 13:09:45 -0700
    > Sam Fischmann <sam.fischmann@gmail.com> wrote:
    >

    > AFAIK xInclude processing isn't a job for an application such
    > as an XSL engine or an editor, it is the job of the XML parser.
    >
    > --
    >
    > regards
    >
    > --
    > Dave Pawson
    > XSLT XSL-FO FAQ.
    > http://www.dpawson.co.uk
    >