XQuery on Any nodes

Dear colleges

We are working with Tamino 4.1.4.1 and having troubles with XQuery and Any nodes. XQuery does not retrieve elements directly adressed if they are included in an Any node. This does not happen with X-Query, and looking at the list, in the topic “XQuery on “Any” element not working” posted by Jim McDowall the 21 August 03 18:21, seems that in Tamino 4.1.1.2 it worked. Unfortunatelly, there was no answer to such topic.

Does any body know if this is a known bug, or ways to by-pass the problem?

Thanks in advance
Almudena & Ignacio

Hi Almudena & Ignacio,

yes this is a known bug in Tamino 4.1, but I am not aware whether it is fixed
in some subversions of Tamino 4.1. It is definetely fixed in Tamino 4.2. In
the meantime I suggest you try to replace the slash (/) following the element
being of type xs:anyType in your XQuery path expression by // and give the name
of the node you are searching afterwards. I.e. if your path falsely yielding
the empty sequence is input()/a/b/c/d and b is of type xs:anyType, try
input()/a/b//d. This helps with my version of Tamino 4.1. Please inform me if
this does not help, in which case I’ll try to find out which subversion of
4.1. will do (if any).

Regards,
Juliane.

Hi Juliane

Yes, it works, thanks a lot.

Next XQUERY does not work:

for $a in input()/STLBibliographicIbermarc
where $a/STLFields/STLCode >= “B2003” and
$a/STLRecord/MarcEstela/B100/B100a
return $a/STLFields/STLCode

Next XQUERY works:

for $a in input()/STLBibliographicIbermarc
where $a/STLFields/STLCode >= “B2003” and
$a/STLRecord//B100/B100a
return $a/STLFields/STLCode

Thanks again.
Almudena & Ignacio

Hello:

I have the same problem that Ignacio had three years ago, but in my case the posted solution doesn’t work. I’m using Tamino 4.4.1.1 and I defined an “Any” element in order to store any xml document. This is my schema:


<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:ino = "http://namespaces.softwareag.com/tamino/response2" xmlns:tsd = "http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" xmlns:xs = "http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <tsd:schemaInfo name = "OrchestratorMessage">
        <tsd:collection name = "Integracion"></tsd:collection>
        <tsd:doctype name = "Message">
          <tsd:logical>
            <tsd:content>closed</tsd:content>
          </tsd:logical>
        </tsd:doctype>
        <tsd:adminInfo>
          <tsd:server>4.4.1.1</tsd:server>
          <tsd:modified>2006-09-21T13:35:41.343+02:00</tsd:modified>
          <tsd:created>2006-09-21T13:35:41.343+02:00</tsd:created>
          <tsd:version>TSD4.4</tsd:version>
        </tsd:adminInfo>
      </tsd:schemaInfo>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name = "Message">
    <xs:complexType>
      <xs:sequence>
        <xs:element name = "ID" type = "xs:string"></xs:element>
        <xs:element name = "timestamp" type = "xs:string"></xs:element>
        <xs:element name = "XMLDocument">
          <xs:complexType>
            <xs:sequence minOccurs = "0">
              <xs:any processContents = "skip" minOccurs = "0"></xs:any>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

I’ve successfully inserted a document:


<Message>
<ID>0123456789</ID>
<timestamp>20061002104510765</timestamp>
<XMLDocument>
  <AnyElement>
    <B>
      <C>hello</C>
    </B>
   </AnyElement>
</XMLDocument>
</Message>

I’m trying with this query’s without success:


for $m in input()/Message where $m/XMLDocument/AnyElement/B/C="hello" return $m

for $m in input()/Message where $m/XMLDocument//B/C="hello" return $m

for $m in input()/Message where $m/XMLDocument/*/B/C="hello" return $m

I’ve tried as well with x-query:


Message[XMLDocument/AnyElement/B/C="hello"]

Message[XMLDocument//B/C="hello"]

Message[XMLDocument/*/B/C="hello"]

No documents are returned. Anyone can help me? Thanks :stuck_out_tongue_winking_eye: !!!

Hi,

I tried exactly your schema, document, query. Works fine. Are you sure you sent the query to the right collection?

Regards

Harald

Hello, Harald:

I’ve just noticed that the XML element inside my “Any” node has a namespace:


<Message>
<ID>0123456789</ID>
<timestamp>20061002104510765</timestamp>
<XMLDocument>
  <AnyElement xmlns="urn:myElements">
    <B>
      <C>hello</C>
    </B>
   </AnyElement>
</XMLDocument>
</Message>

I didn’t noticed it because the “xmlns” attribute doesn’t appear when querying with the Tamino Interactive Interface (I don’t know why).

This namespace is causing the xquery failures. I’ve inserted the same document without any namespace and the xquery works.
Do you know how can I query with namespaces inside the document?

Thanks in advance.

Hi Carlos,

you can either explicitly define the namespace:


declare namespace myns="urn:myElements"
for $m in input()/Message where $m/XMLDocument/myns:AnyElement/B/C="hello" return $m 

or you can use a namespace wildcard:


for $m in input()/Message where $m/XMLDocument/*:AnyElement/B/C="hello" return $m 

Regards

Harald

Thank you Harald, it works, but I have to specify the namespace prefix in all sub-elements:


declare namespace myns="urn:myElements"
for $m in input()/Message where $m/XMLDocument/myns:AnyElement/myns:B/myns:C="hello" return $m 

…or:


for $m in input()/Message where $m/XMLDocument/*:AnyElement/*:B/*:C="hello" return $m 

…or


for $m in input()/Message where $m/XMLDocument/*/*:B/*:C="hello" return $m 

Without specifying namespace prefixes, it doesn’t return anything.

Thanks again :wink:

Hi,

you are right, the prefixes are needed for all elements in the namespace

Regards

Harald