Thank you Christian, for all the prompt replies. It looks like I got it working using *:Ontology. I must say I never understood why namespaces must make things so complicated and counterintuitive.
Another thing that has put me on the wrong track a couple of times is when I want to check with the BaseX UI tool some results that my program inserts into the database, only to get completely different results than I'd expect. It's as if there's interference between my running program and the BaseX UI tool.
For example, if I replace a node using my program and next try to replace the node through the BaseX UI the result is unpredictable. Sometimes it does what I expect, sometimes it gives the old node that was put in by my program and sometimes something I did ten minutes before.
There's probably some explainable system to it, but I haven't figured it out yet.
Mark
On Jan 20, 2011, at 12:21 PM, Christian Grün wrote:
Hi Mark,
this is due to a missing namespace declaration. You can either explicitly specify your namespace...
declare default element namespace "http://www.w3.org/2002/07/owl#"; doc('test')/Ontology
...or use a namespace wildcard to match the root element:
doc('test')/*:Ontology
Hope this helps, Christian
On Thu, Jan 20, 2011 at 11:16 PM, Mark Boon mboon@blueplanetsoftware.com wrote:
OK, I enter the following commands in the BaseX UI. create database test insert node <Ontology/> into doc('test') replace node collection('test')/Ontology with <Ontology xmlns="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:base="http://www.w3.org/2002/07/owl#"> <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/> <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/> <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/> <SubClassOf> <Class IRI="http://ar#boat"/> <Class IRI="http://ar#vehicle"/> </SubClassOf>
</Ontology> Now, if I do collection('test') it shows me that the element was in fact inserted as it prints: <Ontology xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns="http://www.w3.org/2002/07/owl#" xml:base="http://www.w3.org/2002/07/owl#"> <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/> <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/> <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/> <SubClassOf> <Class IRI="http://ar#boat"/> <Class IRI="http://ar#vehicle"/> </SubClassOf> </Ontology> However, if I enter: collection('test')/Ontology it's empty. Isn't that unusual? I do note that in the "Query Info" panel it prints: - removing unknown tag/attribute "Ontology" although it doesn't do so in my larger example. When I try to execute the same 'replace...' command again, it tells me: Error: [XUDY0027] Replace target must not be empty. Mark Boon
On Jan 20, 2011, at 11:39 AM, Christian Grün wrote:
Hi Mark,
I'm sorry, but I think I need some more information to find a helpful answer. Do you have a little example (sscce) that allows us to reproduce the issue?
Christian ___________________________
On Thu, Jan 20, 2011 at 10:27 PM, Mark Boon mboon@blueplanetsoftware.com wrote:
OK, I tried with BaseX 6.5. Now I don't get an error, but now my Ontology
element remains empty.
This is the output of the query:
Query: replace node collection('bm_test_iam')/BOT-L/Ontology with <Ontology
xmlns="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xml:base="http://www.w3.org/2002/07/owl#%22%3E
Compiling:
- pre-evaluating collection("bm_test_iam")
Result: replace node document-node { "bm_test_iam" }/*:BOT-L/*:Ontology with
element { "Ontology" } { attribute { "xml:base" } {
"http://www.w3.org/2002/07/owl#" }, element { "Prefix" } { attribute {
"name" } { "rdf" }, attribute { "IRI" } {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#" } }, element { "Prefix" } {
attribute { "name" } { "rdfs" }, attribute { "IRI" } {
"http://www.w3.org/2000/01/rdf-schema#" } }, element { "Prefix" } {
attribute { "name" } { "xsd" }, attribute { "IRI" } {
"http://www.w3.org/2001/XMLSchema#" } }, element { "Prefix" } { attribute {
"name" } { "owl" }, attribute { "IRI" } { "http://www.w3.org/2002/07/owl#" }
}, element { "SubClassOf" } { element { "Class" } { attribute { "IRI" } {
"http://ar#boat" } }, element { "Class" } { attribute { "IRI" } {
"http://ar#vehicle" } } } }
Query plan:
<Replace>
<IterPath>
<document-node() name="bm_test_iam"/> <IterStep axis="child" test="*:BOT-L"/> <IterStep axis="child" test="*:Ontology"/>
</IterPath>
<CElem>
<Item value="Ontology" type="xs:QName"/> <CAttr> <Item value="xml:base" type="xs:QName"/> <Item value="http://www.w3.org/2002/07/owl#" type="xs:string"/> </CAttr> <CElem> <Item value="Prefix" type="xs:QName"/> <CAttr> <Item value="name" type="xs:QName"/> <Item value="rdf" type="xs:string"/> </CAttr> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
type="xs:string"/>
</CAttr> </CElem> <CElem> <Item value="Prefix" type="xs:QName"/> <CAttr> <Item value="name" type="xs:QName"/> <Item value="rdfs" type="xs:string"/> </CAttr> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://www.w3.org/2000/01/rdf-schema#"
type="xs:string"/>
</CAttr> </CElem> <CElem> <Item value="Prefix" type="xs:QName"/> <CAttr> <Item value="name" type="xs:QName"/> <Item value="xsd" type="xs:string"/> </CAttr> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://www.w3.org/2001/XMLSchema#" type="xs:string"/> </CAttr> </CElem> <CElem> <Item value="Prefix" type="xs:QName"/> <CAttr> <Item value="name" type="xs:QName"/> <Item value="owl" type="xs:string"/> </CAttr> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://www.w3.org/2002/07/owl#" type="xs:string"/> </CAttr> </CElem> <CElem> <Item value="SubClassOf" type="xs:QName"/> <CElem> <Item value="Class" type="xs:QName"/> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://ar#boat" type="xs:string"/> </CAttr> </CElem> <CElem> <Item value="Class" type="xs:QName"/> <CAttr> <Item value="IRI" type="xs:QName"/> <Item value="http://ar#vehicle" type="xs:string"/> </CAttr> </CElem> </CElem>
</CElem>
</Replace>
Timing:
Parsing: 0.87 ms
Compiling: 1.21 ms
Evaluating: 2.33 ms
Printing: 0.14 ms
Total Time: 4.55 ms
When I now do collection('bm_test_iam')/BOT-L/Ontology the "Text" panel just
contains:
<Ontology/>
where I expected it to contain the XML I just inserted.
Mark Boon
On Jan 20, 2011, at 11:13 AM, Mark Boon wrote:
On Jan 20, 2011, at 11:09 AM, Christian Grün wrote:
Mark,
thanks for your mails. Just a short one.. Does the same error occur
with the latest version of BaseX (6.5)?
Christian
Actually, I just picked up this work where I left it a few weeks ago. Some
reorganization at work made me change e-mail so I hadn't followed this list
either. So I missed that a new version came out. I'll try it immediately.
I'll get back with the result.
Mark
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de