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 (I use DOMDocument for working with this XML document) isn't 
entirely conformed with XInclude or XPointer standard?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to