Loading ...
Sorry, an error occurred while loading the content.
 

Re: [xml-doc] Xincludes again

Expand Messages
  • Gareth Oakes
    Once you got to the second part with the xpointer, you made me think of XQuery because it seems you are wanting to do some sort of querying of XML content,
    Message 1 of 3 , Nov 9, 2009
      Once you got to the second part with the xpointer, you made me think of
      XQuery because it seems you are wanting to do some sort of querying of
      XML content, treating it like a database.

      Alternatively I guess an XSLT could be used to resolve your document
      from the component parts.

      Of course, either way, you need <chapter> in the final hierarchy to make
      your Docbook document valid for publishing.

      Regards the ID scheme, if your doctype (Docbook) defines an "id"
      attribute as type ID, then your XML document (the one that is resolved
      from the XInclude) must have a unique value for each "id". It's as
      simple as that. As you suggest, most people would use something like
      "week01_goals" or whatever instead of just "goals".

      -Gareth

      Bill Harris wrote:
      >
      >
      > -----BEGIN PGP SIGNED MESSAGE-----
      > Hash: SHA1
      >
      > I've not used xincludes for a few years. Now I'm in the position where
      > they could be handy, and I've forgotten too much (or they don't do what
      > I want). So far, I haven't found the key in searching on zvon.org,
      > xmlsoft.com, wiki.docbook.org,
      > http://www.ibm.com/developerworks/xml/library/x-reuseinfo2/index.html?ca=drs-,
      > <http://www.ibm.com/developerworks/xml/library/x-reuseinfo2/index.html?ca=drs-,>
      > http://www.sagehill.net/docbookxsl/ModularDoc.html#XincludeSelect,
      > <http://www.sagehill.net/docbookxsl/ModularDoc.html#XincludeSelect,>
      > http://www.w3schools.com/xlink/xlink_example.asp,
      > <http://www.w3schools.com/xlink/xlink_example.asp,>
      > http://www.w3.org/TR/xinclude/#points,
      > <http://www.w3.org/TR/xinclude/#points,> and a few other places (including
      > the archives here).
      >
      > Let's say I'm teaching a course that lasts 3 weeks. I want a file for
      > each week's plan. Each week will have goals, steps in the plan, and
      > homework assignments.
      >
      > I'd like to be able to produce a document that describes the full course
      > as well as documents that describe each week of the course and documents
      > that describe, respectively, the weekly goals, weekly plans, and weekly
      > assignments. Those latter three documents will need section (or
      > chapter) headings for the weeks plus the appropriate content.
      >
      > I'm using xmllint and docbook2pdf or another jade processor, although I
      > could be convinced to change (I'm on Ubuntu).
      >
      > The top-level document for the full document might look like:
      >
      > <?xml version="1.0"?>
      > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
      > "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
      > <http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd>">
      > <book>
      > <title>Course Title</title>
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week01.xml" />
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week02.xml" />
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week03.xml" />
      > </book>
      >
      > A sample week's document might look like
      >
      > <?xml version="1.0"?>
      > <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
      > "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
      > <http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd>">
      > <chapter id="week01">
      > <title>Week 1</title>
      > <section id="goals">
      > <title>Goals</title>
      > <para>
      > Some goals.
      > </para>
      > </section>
      >
      > <section id="steps">
      > <title>Detailed Plan Steps</title>
      > <para>
      > I might put a list of steps here.
      > </para>
      > </section>
      >
      > <section id="homework">
      > <title>Homework</title>
      > <para>
      > How to do the homework. What the assignments are.
      > </para>
      > </section>
      >
      > </chapter>
      >
      > xmllint --xinclude works fine. I've got two problems when running
      > docbook2pdf.
      >
      > First, I now have multiple pieces with the same id, and docbook doesn't
      > like that. Is there a natural organization I'm missing? Sure, I could
      > give each id the form toplevelid.lowerlevelid or some such, but that
      > gets wordy, and it may make the second part difficult.
      >
      > Second, even if I only include the first file, there's a problem when I
      > want to include only parts of the file. I'd like a file something like
      >
      > <?xml version="1.0"?>
      > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
      > "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
      > <http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd>">
      > <book>
      > <title>Course Title</title>
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week01.xml"
      > xpointer="goals" />
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week02.xml"
      > xpointer = "goals" />
      > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude
      > <http://www.w3.org/2001/XInclude>" href="week03.xml" xpointer="goals"/>
      > </book>
      >
      > but that doesn't quite work. While I'd like the week0n chapters and
      > week0n goals sections to be included, this only includes the section.
      > DocBook is unhappy because it's missing a chapter element, and I'm
      > unhappy because I know I wouldn't know what week it was if it had
      > worked.
      >
      > Comments? Tips? I suspect it's simple.
      >
      > Thanks,
      >
      > Bill
      > - --
      > Bill Harris http://facilitatedsystems.com/weblog/
      > <http://facilitatedsystems.com/weblog/>
      > Facilitated Systems Everett, WA 98208 USA
      > http://facilitatedsystems.com/ <http://facilitatedsystems.com/> phone:
      > +1 425 374-1845
      > -----BEGIN PGP SIGNATURE-----
      > Version: GnuPG v1.4.9 (GNU/Linux)
      >
      > iEYEARECAAYFAkr3XxUACgkQ3J3HaQTDvd9xQQCfeM/c1Mk72X9phlFHuYRgfUJx
      > cCcAn2IJoLxYMTWoYz7XbvoAolLYjEOe
      > =xL8S
      > -----END PGP SIGNATURE-----
      >
      >
    • Bill Harris
      ... I forgot about XQuery. It does sound worth reading up on again. ... That I expected. ... Thanks, Gareth. I think that is key to my solution. Bill -- Bill
      Message 2 of 3 , Nov 9, 2009
        Gareth Oakes <lists@...> writes:

        > Once you got to the second part with the xpointer, you made me think of
        > XQuery because it seems you are wanting to do some sort of querying of
        > XML content, treating it like a database.

        I forgot about XQuery. It does sound worth reading up on again.

        > Alternatively I guess an XSLT could be used to resolve your document
        > from the component parts.

        ... assuming I was proficient at that already. :-)

        > Of course, either way, you need <chapter> in the final hierarchy to make
        > your Docbook document valid for publishing.

        That I expected.

        > Regards the ID scheme, if your doctype (Docbook) defines an "id"
        > attribute as type ID, then your XML document (the one that is resolved
        > from the XInclude) must have a unique value for each "id". It's as
        > simple as that. As you suggest, most people would use something like
        > "week01_goals" or whatever instead of just "goals".

        Thanks, Gareth. I think that is key to my solution.

        Bill
        --
        Bill Harris http://facilitatedsystems.com/weblog/
        Facilitated Systems Everett, WA 98208 USA
        http://facilitatedsystems.com/ phone: +1 425 374-1845
      Your message has been successfully submitted and would be delivered to recipients shortly.