Hi

A bit laborious to recreate but .. here goes:

basexclient ... insert nodes then run:

> xquery /
<a>
  <b/>
  <d>
    <e test="here"/>
  </d>
</a>
Query executed in 0.2 ms.

No problem - I see what I expect. Then run this:


> xquery insert node <c>{http:send-request( <http method='get' status-only='false'/>, "http://internet.org.uk" ) }</c> into /a

Query executed in 502.05 ms.
> xquery /
<a>
  <b/>
  <d>
    <e test="here"/>
  </d>
  <c>
    <http:response xmlns:http="http://expath.org/ns/http-client" status="200" message="OK">
...
... SNIPPED THE MIDDLE BODY OUT AS IT'S THE HTML RETURNED FROM THE SITE
...
  </c>
</a>
Query executed in 1.7 ms.


> xquery insert node <f/> into /a/d                  


Query executed in 1.34 ms.
> xquery /
<a>
  <b/>
  <d>
    <e test="here"/>
    <f/>
  </d>
  <c>
    <http:response xmlns:http="http://expath.org/ns/http-client" status="200" message="OK">
      <http:header name="Expires" value="Mon, 26 Jul 1997 05:00:00 GMT"/>
      <http:header name="Last-Modified" value="Mon, 02 Apr 2012 15:47:39 GMT"/>
      <http:header name="Set-Cookie" value="mosvisitor=1"/>
...
...
...
  </c>
</a>
Query executed in 1.72 ms.



> xquery delete node /a/d
Query executed in 1.54 ms.

> xquery insert node <d/> into /a

Query executed in 1.56 ms.
> xquery insert node <h test='hello'><i/></h> into /a/d

Query executed in 1.76 ms.
> xquery /
<a>
  <b/>
  <c>
    <http:response xmlns:http="http://expath.org/ns/http-client" status="200" message="OK">
      <http:header name="Expires" value="Mon, 26 Jul 1997 05:00:00 GMT"/>
...
...
...
  </c>
  <d>
    <h xmlns="http://www.w3.org/1999/xhtml" test="hello">
      <i/>
    </h>
  </d>
</a>
Query executed in 1.71 ms.



---
So, item 'h' suddenly gains a namespace.

Sorry it's a bit convoluted to recreate, but it gets the results I see. 

Cheers
Mike




On 2 Apr 2012, at 16:18, Lukas Kircher wrote:

Ok, I see the problem, unfortunately I still can't replicate the
issue with our current repository version. I started with a
document like this:

<a> <b/> </a>

and used the following insert statements:

insert node <c xmlns='newns'/> into /a

and afterwards ...

insert node <d/> into /a


Still, there's no namespace linked to <d/>. Can you replicate
the issue with this example or change it in a way that it
replicates it?

Regards,
Lukas




On Mon, Apr 2, 2012 at 5:10 PM, Mike Hawkes <mikehawkes@me.com> wrote:
Yep - this definitely causes problems. Insert a node that includes a namespace and all subsequent nodes end up with a namespace inserted. So ... I think this presents a bug:

<root>
    <nodes without namespace/>
    <new nodes work well/>
</root>

vs.

<root>
    <nodes without namespace/>
    <node with namespace/>
    <new nodes automatically get spurious namespace/>
</root>


Hope that helps - not sure how best to fix or work around this at the moment though.

Cheers
Mike

On 2 Apr 2012, at 15:23, Mike Hawkes wrote:

Hi Lukas/Christian

It's the built-in one as far as I'm aware - I haven't done anything special to add or remove any parsers. But that's sent me down a path where I can get it reliably.

It appears that it's coming from another query that I run to check the state of a web-site. As soon as I run the following query, BaseX inserts the namespace for every inserted node thereafter:

insert node 
    <webpage url="http://internet.org.uk" name="primaryDomain">{
        http:send-request( 
            <http:request 
                method='get' 
                status-only='false'/>, 
        "http://internet.org.uk" )}
    </webpage>
into doc($DB)/root/webpages

As soon as I have any node after the above query has run, BaseX inserts the namespace. Otherwise it doesn't. If I delete all the nodes within the <webpage> tags, things return to normal again.

Is there an easy way to do the above without adding any namesakes (I don't actually want to include them from the web query either)? This should solve the problem.

Cheers
Mike

On 2 Apr 2012, at 15:02, Lukas Kircher wrote:

Hi Mike,

Leo just came up with another idea: Which kind of parser are
you using in BaseX?

If you use the HTML parser for parsing XML, the strange behaviour
you came across might indeed be expected ... If you're not sure
which parser you are using, just take a look at our documentation [1].

Regards,
Lukas




On Mon, Apr 2, 2012 at 3:58 PM, Mike Hawkes <mikehawkes@me.com> wrote:
It's mad - I don't add a namespace, the source document is a text file without a namespace - and the log shows that I don't add it ... but it appears. No idea why.

MIke

On 2 Apr 2012, at 14:52, Christian Grün wrote:

> So it seems that the once added namespace is propagated to other
> documents? I believe there must be at least one document with the
> mentioned namespace in your database; otherwise I can't explain where
> it should come from (afaik, the string "http://www.w3.org/1999/xhtml"
> isn't hard-coded anywhere in the project)...
>
> Christian
> ___________________________________
>
> On Mon, Apr 2, 2012 at 3:40 PM, Mike Hawkes <mikehawkes@me.com> wrote:
>> The database contains
>>
>> <root>
>>    <auditlog>
>>
>> ... elements should end up in here ...
>>
>>    </auditlog>
>> </root>
>>
>>
>> The initial XML file contains the initial nodes with which to populate the XML database (root plus numerous other nodes). The PHP code inserts additional nodes as it runs. For every node I add, I create an audit entry to allow me to determine who and how the database built over time.
>>
>> initialdb.xml contains, therefore:
>> <root>
>>    <auditlog/>
>> </root>
>>
>> You're right - ignore 'test'  - I meant WYP in the database - as in
>>
>> drop database WYP
>> create database WYP test/initialdb.xml
>>
>> Apologies for any confusion caused.
>>
>> It's really weird - I can't get this to fail consistently - but when it starts inserting the namespace attribute, it then continues to do so.
>>
>> Cheers
>> Mike
>>
>> On 2 Apr 2012, at 14:30, Christian Grün wrote:
>>
>>> Sorry, I still got some questions..
>>>
>>>> drop database test
>>>> create database test /initialdb.xml
>>>
>>> The database you're creating seems to be called "test"; what's "initialdb.xml"?
>>>
>>>> 14:00:00.710    [127.0.0.1:49788]       QUERY(4)        declare variable $DB external; insert node <audit QID='80C18E9A-46DD-4B3E-89E9-967DAFD79A0B' UID='i1' guid='0EEDDB47-726E-49F8-B1EF-0F73ED848969' sessionID='48090b7f0e3a62a42a0457a3e88301ca' mode='active' date='2012-04-02T13:00:00+00:00'/> into doc($DB)/root/auditlog     OK      0.09 ms
>>>> 14:00:00.710    [127.0.0.1:49788]       QUERY(4)        OK      0.05 ms
>>>> 14:00:00.710    [127.0.0.1:49788]       BIND(4) DB      WYP             OK      0.05 ms
>>>
>>> The log info implies you're having "root" and "auditlog" nodes, and
>>> the addressed database is called "WYP", is that right? Could you pass
>>> us on the missing snippets?
>>>
>>> Christian
>>>
>>>
>>>
>>>> On 2 Apr 2012, at 14:11, Christian Grün wrote:
>>>>
>>>>> Hi Mike,
>>>>>
>>>>> thanks for your report. It would be great if you could provide us with
>>>>> a small example that allows us to reproduce the issue (an export of
>>>>> your original database with the namespace (which is being added to the
>>>>> new node) may suffice).
>>>>>
>>>>> Best,
>>>>> Christian
>>>>> ____________________________
>>>>>
>>>>> On Mon, Apr 2, 2012 at 2:44 PM, Mike Hawkes <mikehawkes@me.com> wrote:
>>>>>> Hi
>>>>>>
>>>>>> I have a weird problem ... I'm running a query via the PHP interface and run the following query:
>>>>>>
>>>>>> declare variable $DB external;
>>>>>>
>>>>>> insert node
>>>>>>    <audit QID='C54B14ED-C748-4DF0-87F2-91F505BE207B'
>>>>>>                UID='i1'
>>>>>>                guid='CC9D4D2B-B380-494B-B0F6-4D72471557B0'
>>>>>>                sessionID='48090b7f0e3a62a42a0457a3e88301ca'
>>>>>>                mode='active'
>>>>>>                date='2012-04-02T12:21:05+00:00'/>
>>>>>> into doc($DB)/root/auditlog
>>>>>>
>>>>>> --
>>>>>> BaseX log shows that it gets the query as-is.
>>>>>>
>>>>>> When I look at the data within the database by running the XQuery
>>>>>>
>>>>>> /root/auditlog
>>>>>>
>>>>>> I find that BaseX has inserted a namespace attribute as follows:
>>>>>>
>>>>>> <audit xmlns="http://www.w3.org/1999/xhtml"
>>>>>>    QID="C54B14ED-C748-4DF0-87F2-91F505BE207B"
>>>>>>    UID="i1" guid="CC9D4D2B-B380-494B-B0F6-4D72471557B0" sessionID="48090b7f0e3a62a42a0457a3e88301ca" mode="active" date="2012-04-02T12:21:05+00:00"/>
>>>>>>
>>>>>> How do I stop this occurring? It only does it on the audit components, not on anything else inserted by the PHP script. So, if I run two insert node queries, the first will run normally, the audit update causes the xmlns attribute to appear, effectively putting it in a different namespace to the other data inserted  by the PHP.
>>>>>>
>>>>>> The PHP script is as follows:
>>>>>>
>>>>>> $audit = "declare variable \$DB external; " .
>>>>>>        "insert node <audit QID='$queryID' UID='$userID' " .
>>>>>>        "guid='$guid' sessionID='" . session_id() . "' " .
>>>>>>        "mode='active' " .
>>>>>>        "date='$dateTime'/> into doc(\$DB)/root/auditlog";
>>>>>>
>>>>>> $query = $session->query( $audit );
>>>>>> $query->bind( 'DB', $DB);
>>>>>> $query->bind( 'SYSDATA', $SYSDATA );
>>>>>> $query->execute();
>>>>>> $query->close();
>>>>>>
>>>>>>
>>>>>> Thanks in advance for any suggestions.
>>>>>>
>>>>>> Mike
>>>>>> _______________________________________________
>>>>>> BaseX-Talk mailing list
>>>>>> BaseX-Talk@mailman.uni-konstanz.de
>>>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>>>
>>

_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk


_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk