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

David Cramer david.cramer at rackspace.com
Tue Sep 17 05:20:48 UTC 2013


On 09/16/2013 11:44 PM, Sean Roberts wrote:
> I was able to
> get <xi:includehref="../install-guide/basic-install-files/basic-install_architecture.xml"xpointer="xmlns(db=http://docbook.org/ns/docbook)
> xpath(//*[@xml:id = 'basic-install_architecture'])"> to work where the
> xml:id matches an xml:id in the included file. 

But that would just be the same thing as xincluding the file with no
xpointer at all. You can also xinclude by id without using the xpath()
stuff.

> but what I really like to do is something like 
> <xi:includehref="../install-guide/basic-install-files/basic-install_architecture.xml"xpointer="xmlns(db=http://docbook.org/ns/docbook)
> xpath(//*[@xml:id = 'basic-install_architecture']/*[not(self:db:chapter)])">

Try this (note that oXygen will complain but the Maven plugin should
take it and do the right thing):

<xi:include
href="../install-guide/basic-install-files/basic-install_architecture.xml"
xpointer="xmlns(db=http://docbook.org/ns/docbook)
xpath(/db:chapter/*)">

or more generically:

<xi:include
href="../install-guide/basic-install-files/basic-install_architecture.xml"
xpointer="xpath(/*/*)">

What the xpath /db:chapter/* says is: give me all of the child elements
of db:chapter

If you want the contents of the chapter except for the title, do
xpath(/db:chapter/*[not(self::db:title)])

Let me know if you can't get it working and what doc you're trying to do
it in. I'll give it a shot, but I did test this and it works with the
clouddocs-maven-plugin (recent versions anyway).

David

> 
> where I could include content, but strip out the source path hierarchy
> and replace it with new. 
> The reasoning is to change source chapters or sections into just raw
> content that could be inserted into an existing section or chapter. 
> 
> 
> Sean Roberts
> Infrastructure Strategy
> seanrob at yahoo-inc.com <mailto:seanrob at yahoo-inc.com> (925) 980-4729
> 
> On Aug 6, 2013, at 1:37 PM, David Cramer <david.cramer at rackspace.com
> <mailto:david.cramer at rackspace.com>> wrote:
> 
>> On 08/06/2013 02:41 PM, Sean Roberts wrote:
>>> oxygen is complaining about pointer scheme xpath is not supported and
>>> that a well-formed document requires a root element
>>> maven fails with expression could not be evaluated.
>>>
>>> <chapterxmlns="http://docbook.org/ns/docbook"
>>>  xmlns:xi="http://www.w3.org/2001/XInclude"
>>>  xmlns:xlink="http://www.w3.org/1999/xlink"version="5.0"
>>>  xml:id="bk001-ch003-associate-general">
>>>  <title>Associate General</title>
>>> <xi:includehref="../basic-install/src/basic-install_controller-common.xml"xpointer="xmlns(db=http://docbook.org/ns/docbook)
>>> xpath(//*[@xml:id = 'controller-os']/*[not(self::db::title)])">
>>
>> Ok, change self::db::title to self::db:title (just a single colon
>> between the namespace prefix and the element name).
>>
>> You will see that warning in Oxygen, but it's just a warning (not a
>> validation error). This is because Oxygen doesn't recognize the xpointer
>> schemes. I'll contact Oxygen to ask if they plan to add support for the
>> xmlns and xpath schemes.
>>
>> Btw., it looks like the content you're including uses conditional
>> text/profiling. So you'll want to add to the configuration section of
>> your pom a param to indicate which profile you want (e.g. ubuntu).
>> Otherwise you get all conditions:
>>
>> <profileOs>ubuntu</profileOs>
>>
>> David
> 




More information about the Openstack-docs mailing list