W3C home > Mailing lists > Public > public-xml-processing-model-comments@w3.org > May 2011

Nested XIncludes

From: Nimruhil <nimruhil@yandex.ru>
Date: Sat, 30 Apr 2011 06:09:27 +0400
Message-ID: <1069775EE2324649BBEFA00FD0A584CF@someorga5aa935>
To: <public-xml-processing-model-comments@w3.org>
I need to insert a content of an XML node into text of another XML element 
in the same document. I use XInclude for this purpose. For example:

<?xml version="1.0" encoding="UTF-8"?>
<pool xmlns:xi="http://www.w3.org/2001/XInclude">

    <query name="foo">

        <sql db="oracle">Lorem ipsum</sql>

        <sql db="mysql">sed do eiusmod tempor</sql>

    </query>

    <query name="bar">

        <sql db="oracle"><xi:include 
xpointer="xpointer(//query[@name='foo']/sql[@db='oracle']/text( ))" /> dolor 
sit amet,</sql>

        <sql db="mysql"><xi:include 
xpointer="xpointer(//query[@name='bar']/sql[@db='oracle']/text( ))" /> 
consectetur adipisicing elit</sql>

    </query>

</pool>

It works well when a node what content is inserted from contains only text 
(e.g., first sql node in the "foo" query in example above). So I have "Lorem 
ipsum dolor sit amet," in the first sql node in the "bar" query after 
parsing. That's what I want.

But I have a problem when I try to insert a content of a node containing 
xi:include. For example I have " dolor sit amet, consectetur adipisicing 
elit" instead of "Lorem ipsum dolor sit amet, consectetur adipisicing elit" 
in the second sql node within the "bar" query. When I use xpointer without 
text( ) at end I have the following as content of the second sql node within 
the "bar" query:

<sql xmlns:xi="http://www.w3.org/2001/XInclude" db="oracle">Lorem ipsum 
dolor sit amet,</sql> consectetur adipisicing elit

It's almost correct, but here are undesirable sql tags. I've tried to use 
range-inside() function of xpointer in this way:

...
        <sql db="mysql"><xi:include 
xpointer="xpointer(range-inside(//query[@name='bar']/sql[@db='oracle']))" /> 
consectetur adipisicing elit</sql>
...

Content of the second sql node in the "bar" query has been changed to this:

<sql db="oracle"/> consectetur adipisicing elit

As you can see content of included sql node entirely gone.

What's wrong? Am I using XInclude or XPointer in the wrong way? Or may be 
PHP XML parser isn't entirely conformed with XInclude or XPointer standard? 
Received on Monday, 2 May 2011 07:53:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 2 May 2011 07:53:23 GMT