OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] How do I reference the title of another xml document?


Hi Grant,
I see what you are trying to do, but I'm afraid you are working with invalid XML. The article element is in the DocBook 5 namespace, but DB5 replaced articleinfo with info. Also you are creating an invalid document with your XInclude. XInclude copies the element being referenced into the current document. So when you use:

<para>
  <xi:include href="samplearticle.xml" xpointer="element(SectionID)" />
</para>

the XML parser sees this after the XInclude is processed:

<para>
  <section xml:id="SectionID">
    <para>The quick ... </para>
  </section>
</para>

Putting a section inside a para is not valid, and the behavior of the stylesheets may render the text of just the para, but only because there is no title in the section.

Similarly, something like this:

<xi:include href="article1.xml" xpointer="element(Title)" />
<xi:include href="article2.xml" xpointer="element(Title)" />

will produce an invalid sequence of title elements, each of which is out of its original context.

Here is how I would set this up to pull in the title text and still have a valid document to process.

1.  Add a phrase element with xml:id to the title of each article:

<article version="5.0" xmlns="http://docbook.org/ns/docbook";>
  <info>
    <title><phrase xml:id="titletext1">Sample Article</phrase></title>
  </info>
  ...


2.  In your including document, use something like this:

<para><xi:include href="article1.xml" xpointer="element(titletext1)" /></para> <para><xi:include href="article2.xml" xpointer="element(titletext2)" /></para>
...

After the XInclude is processed, this will result in a valid para:

<para><phrase xml:id="titletext1">Sample Article</phrase></para>

--
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net




On 12/31/2013 7:50 PM, Grant Taylor wrote:
How do I reference the title of another xml document?

I have the following sample article document:

     <?xml version='1.0' encoding="UTF-8"?>
     <article version="5.0" xmlns="http://docbook.org/ns/docbook";
xmlns:xi="http://www.w3.org/2001/XInclude"; >
         <articleinfo>
             <title xml:id="TitleID">Sample Article</title>
         </articleinfo>
         <section xml:id="SectionID">
             <para>The quick brown fox jumped over the lazy dog.</para>
         </section>
     </article>

I would like to reference the <title> of multiple articles stored in
separate files to make what would be an aggregate listing of articles.

I have the following xinclude article summary document:

     <?xml version='1.0' encoding="UTF-8"?>
     <article version="5.0" xmlns="http://docbook.org/ns/docbook";
xmlns:xi="http://www.w3.org/2001/XInclude"; >
         <articleinfo>
             <title>XInclude Test</title>
         </articleinfo>
         <section>
             <para>Testing xinclude / xpointer code below.</para>
             <para>
                 <xi:include href="samplearticle.xml"
xpointer="element(SectionID)" />
             </para>
         </section>
     </article>

I have gotten references to the section to work, but I haven't been able
to figure out how to reference the title of the reference document.

Ultimately I'd like to be able to have an aggregate listing (manually
created) that references the titles of multiple other documents.

<xi:include href="article1.xml" xpointer="element(Title)" />
<xi:include href="article2.xml" xpointer="element(Title)" />
...
<xi:include href="articleN.xml" xpointer="element(Title)" />

So, how do I reference the title of a referenced document?

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org








[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]