[Openstack-docs] Use of XML xi:include with xpointer

Shaun McCance shaunm at gnome.org
Wed Jul 31 15:36:30 UTC 2013


XInclude doesn't let you add child elements to the included element,
but you can include multiple elements with XInclude, just not with
the element() scheme. The xpointer() scheme allows you to use XPath,
so you can put something at the end by manually duplicating the
section element, then including the child content of the target
section element:

<section id="some_id">
  <xi:include href="some_file.xml"
             xpointer="xpointer(id('some_id')/*)"/>
  <para>Something at the end</para>
</section>

It's more complicated to put something at the beginning, because
you have to account for things like title and info elements. Not
accounting for titleabbrev and subtitle:

<section id="some_id">
  <xi:include href="some_file.xml"
             xpointer="xmlns(db=http://docbook.org/ns/docbook)
                       xpointer(id('some_id')/db:title)">
    <xi:fallback/>
  </xi:include>
  <xi:include href="some_file.xml"
             xpointer="xmlns(db=http://docbook.org/ns/docbook)
                       xpointer(id('some_id')/db:info)">
    <xi:fallback/>
  </xi:include>
  <para>Something at the beginning</para>
  <xi:include href="some_file.xml"
             xpointer="xmlns(db=http://docbook.org/ns/docbook)
                       xpointer(id('some_id')/*
                       [not(self::db:title or self::db:info)]
                       )"/>
  <para>Something at the end</para>
</section>

Kind of messy, but still more long-term maintainable than manually
including each child element of the target section.

I wrote a howto on XInclude a couple years back, which you might
find useful:

http://blogs.gnome.org/shaunm/2011/07/21/understanding-xinclude/

--
Shaun

On Wed, 2013-07-31 at 02:41 +0000, Sean Roberts wrote:
> Both actually. I want to place a submit bug link at the end of each
> section. Also want to add some text at the beginning for many of the
> included sections describing training objectives. 
> 
> 
> I'd also be interested in ideas on using xslt to rip and replace tags.
> But that probably can wait a little bit. 
> 
> ~sean
> 
> On Jul 30, 2013, at 9:18, "Anne Gentle"
> <annegentle at justwriteclick.com> wrote:
> 
> 
> > Hi Sean, 
> > Do you want some sort of "glue text" so that the guide can be read
> > in a linear way? Or is it text that you'll use over and over, such
> > as "Now go take the test." Let us know what you're trying to do. 
> > 
> > 
> > You can't really strip a tag at a time without XSLT (the transform
> > code that lives in the Maven plugin).
> > Anne
> > 
> > 
> > On Tue, Jul 30, 2013 at 9:19 AM, Sean Roberts
> > <seanrob at yahoo-inc.com> wrote:
> >         Ideas on how to add text to the included section or final
> >         page? Part of the problem may be from that I'm stuck using
> >         the chapter or section of the original XML. If I could
> >         include, strip the section tags, then I could add text no
> >         problem. 
> >         
> >         ~sean
> >         
> >         On Jul 30, 2013, at 6:54, "Anne Gentle"
> >         <annegentle at justwriteclick.com> wrote:
> >         
> >         
> >         > I think DocBook sees the markup as a closed section
> >         > followed by a para whic is invalid.
> >         > 
> >         > Anne Gentle 
> >         > Content Stacker
> >         > anne at openstack.org
> >         > 
> >         > 
> >         > 
> >         > On Jul 30, 2013, at 8:38 AM, Sean Roberts
> >         > <seanrob at yahoo-inc.com> wrote:
> >         > 
> >         > 
> >         > > I am pulling in a section through <xi:include
> >         > > href="http.....xpointer="element(foobar)"></xi:include>
> >         > > If I want to use additional text, I'm forced to make it
> >         > > a section as well. I want to add text to the beginning
> >         > > or end of the the included section. 
> >         > > I tried <xi:include
> >         > > href="http.....xpointer="element(foobar)"><para>blah
> >         > > blah</para></xi:include>
> >         > > , which shows up without error in oxygen, but maven
> >         > > seems to strip it out during HTML build. 
> >         > > 
> >         > > ~sean
> >         > > 
> >         > > On Jul 30, 2013, at 6:24, "Anne Gentle"
> >         > > <annegentle at justwriteclick.com> wrote:
> >         > > 
> >         > > 
> >         > > > Hi Sean,  
> >         > > > Post your XML code so we can take a closer look, or a
> >         > > > link to the patch and the file name so we can look at
> >         > > > it. 
> >         > > > Thanks!
> >         > > > Anne
> >         > > > 
> >         > > > 
> >         > > > On Tue, Jul 30, 2013 at 2:56 AM, Sean Roberts
> >         > > > <seanrob at yahoo-inc.com> wrote:
> >         > > >         I have another question. I'm bringing in the
> >         > > >         sections which is the smallest page into the
> >         > > >         built HTML. I'm trying to add text and links
> >         > > >         within the final HTML page without success.
> >         > > >         Oxygen shows the link and text fine, but the
> >         > > >         maven built site only has the included
> >         > > >         section. Perhaps some adjustment within the
> >         > > >         pom file...
> >         > > >         
> >         > > >         ~sean
> >         > > >         
> >         > > >         On Jul 29, 2013, at 9:34, "Diane Fleming"
> >         > > >         <diane.fleming at rackspace.com> wrote:
> >         > > >         
> >         > > >         
> >         > > >         > I don't know if this will work, but this is
> >         > > >         how I used xpointer to pull in
> >         > > >         > content from one file to another:
> >         > > >         >
> >         > > >         >
> >         > > >         > Target file (pulls in content)
> >         > > >         >
> >         > > >         > <title>Overview</title>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over1)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over2)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over3)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over4)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over5)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over6)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over7)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over8)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over9)"/>
> >         > > >         > <xi:include href="ch_gs_overview.xml"
> >         > > >         >                xpointer="element(over10)"/>
> >         > > >         > <xi:include href="section_virt_ext.xml"/>
> >         > > >         >
> >         > > >         >
> >         > > >         >
> >         > > >         > Source file
> >         > > >         >
> >         > > >         >
> >         > > >         >    <title>Overview</title>
> >         > > >         >    <section
> >         > > >         xml:id="cn_overview"><title>Cloud
> >         > > >         Networks</title>
> >         > > >         >    <para xml:id="over1">Cloud Networks lets
> >         > > >         you create a virtual
> >         > > >         >        Layer 2 network, known as an isolated
> >         > > >         network, which gives you
> >         > > >         >        greater control and security when you
> >         > > >         deploy web applications.
> >         > > >         > </para>
> >         > > >         >    <para xml:id="over2">When you create a
> >         > > >         next generation Cloud
> >         > > >         >        Server, Cloud Networks enables you to
> >         > > >         attach one or more
> >         > > >         >        networks to your server. You can
> >         > > >         attach an isolated network
> >         > > >         >        that you have created or a Rackspace
> >         > > >         network. </para>
> >         > > >         >    <para xml:id="over3">If you install the
> >         > > >         &virt_ext;, you can create
> >         > > >         >        a virtual interface to a specified
> >         > > >         Rackspace or isolated
> >         > > >         >        network and attach that network to an
> >         > > >         existing server
> >         > > >         >        instance. You can also list virtual
> >         > > >         interfaces for and delete
> >         > > >         >        virtual interfaces from a server
> >         > > >         instance. For information
> >         > > >         >        about the &virt_ext;, see <xref
> >         > > >         linkend="section_virt_ext"
> >         > > >         >        />.</para>
> >         > > >         >
> >         > > >         >
> >         > > >         > etc.
> >         > > >         >
> >         > > >         >
> >         > > >         > Diane
> >         > > >         >
> >         > > >         >
> >         > > >         ----------------------------------------------
> >         > > >         > Diane Fleming
> >         > > >         > Software Developer II - US
> >         > > >         >
> >         > > >         > diane.fleming at rackspace.com
> >         > > >         > Cell  512.323.6799
> >         > > >         > Office 512.874.1260
> >         > > >         > Skype drfleming0227
> >         > > >         > Google-plus diane.fleming at gmail.com
> >         > > >         >
> >         > > >         >
> >         > > >         >
> >         > > >         >
> >         > > >         >
> >         > > >         >
> >         > > >         > On 7/29/13 9:27 AM, "Sean Roberts"
> >         > > >         <seanrob at yahoo-inc.com> wrote:
> >         > > >         >
> >         > > >         >> I'm working on reusing content from remote
> >         > > >         XML formatted sources to
> >         > > >         >> create new content. I'm using xi:include
> >         > > >         xpointer to a section of an
> >         > > >         >> existing XML file. Using the editor oxygen
> >         > > >         I can see the remote content,
> >         > > >         >> so I know my href is valid. But maven fails
> >         > > >         to build the html from the
> >         > > >         >> xml returning bad pointer.
> >         > > >         >>
> >         > > >         >> The remote content isn't using DTD or
> >         > > >         XMLschema. I'm hoping I can figure
> >         > > >         >> out how to walk the structure without
> >         > > >         having to.
> >         > > >         >> Any XML peoples that can help?
> >         > > >         >>
> >         > > >         >> ~sean
> >         > > >         >>
> >         > > >         _______________________________________________
> >         > > >         >> Openstack-docs mailing list
> >         > > >         >> Openstack-docs at lists.openstack.org
> >         > > >         >>
> >         > > >         http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs
> >         > > >         >
> >         > > >         >
> >         > > >         
> >         > > >         _______________________________________________
> >         > > >         Openstack-docs mailing list
> >         > > >         Openstack-docs at lists.openstack.org
> >         > > >         http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs
> >         > > >         
> >         > > > 
> >         > > > 
> >         > > > 
> >         > > > 
> >         > > > -- 
> >         > > > Anne Gentle
> >         > > > annegentle at justwriteclick.com
> > 
> > 
> > 
> > 
> > -- 
> > Anne Gentle
> > annegentle at justwriteclick.com
> _______________________________________________
> Openstack-docs mailing list
> Openstack-docs at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs





More information about the Openstack-docs mailing list