I have this canonical structure:
<xsd:complexType name="Document">
<xsd:attribute name="ID" use="optional" type="cdpscm:IDDocument"/>
</xsd:complexType>
<xsd:element name="NationalID" type="cdpscm:NationalID"/>
<xsd:complexType name="NationalID">
<xsd:complexContent>
<xsd:extension base="cdpscm:Document">
<xsd:sequence>
<xsd:element name="Number"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="Passaport" type="cdpscm:Passaport"/>
<xsd:complexType name="Passaport">
<xsd:complexContent>
<xsd:extension base="cdpscm:Document">
<xsd:sequence>
<xsd:element name="Number"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Who calls my OSB service will cast if the document is a Passaport or a NationalID, but how I get the number value to pass to another service, for example, if I only have the Document element type which doesn't has the number element.
This is the supossed input:
<v24:Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="v2:TouristPerson" ID="5772893">
<v2:Documents>
<v2:Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="v2:Passport">
<v2:Number>03070</v2:Number>
</v2:Document>
</v2:Documents>
</v24:Person>
The real structure is more complex than this, so probably will need to know if I'm working with NationalID or Passaport, a Tourist or a Native Person.
Using Oracle 11g, Eclipse OEPE.
Thanks for the help!
Something like this should work.
declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
let $documents := $body//v24:Person/v2:Documents/v2:Document
for $passport in $documents[@xsi:type="v2:Passport"]
return data($passport/v2:Number)
(: similarly for national IDs :)