IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Importing XSchema into Tamino

    Posted Tue November 11, 2003 05:13 PM

    Hi,
    for a class on XQuery someone wrote a simple XSchema from scratch and a sample instance. Both get evaluated for example by http://apps.gotdotnet.com/xmltools/xsdvalidator/; the Schema can be opened with the Tamino Schema Editor, validated and defined for a new database.

    It is even possible to insert data to the database, but: I ran into problems querying the data.
    A simple query like:
    for $a in input() return $a
    or X-Query for /
    works fine, but anything more complicated results in an illegal cursor position or something like that. This is especially true for XPath expressions, however easy they are (yes, I checked spelling, etc. )

    I can’t see any reason for that, but maybe someone of you will see it. Maybe it has something to do with self-defined (complex) data types? I never did this before, as all my other databases were based on a DTD and not on XSchema.

    See Schema below and sample instance (no, that is not an actual person, just sample data).


    <?xml version="1.0" encoding="utf-8"?>
    <xsd:schema xmlns:xsd=“XML Schema
    xmlns=“http://example.com/addressList
    targetNamespace=“http://example.com/addressList
    elementFormDefault=“qualified”>

    <xsd:element name=“addressList” type=“AddressListType”/>

    <xsd:complexType name=“AddressListType”>
    xsd:sequence
    <xsd:element name=“address” type=“AddressType” minOccurs=“0” maxOccurs=“50”/>
    </xsd:sequence>
    <xsd:attribute name=“Revision”>
    xsd:simpleType
    <xsd:restriction base=“xsd:date”>
    <xsd:pattern value=“2003-\d{2}-\d{2}”/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name=“AddressType”>
    xsd:choice
    <xsd:element name=“person” type=“PersonType”/>
    <xsd:element name=“firm” type=“FirmType”/>
    </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name=“PersonType”>
    xsd:sequence
    <xsd:element name=“pName” type=“PNameType”/>
    <xsd:element name=“street” type=“NameType”/>
    <xsd:element name=“number” type=“NrType”/>
    <xsd:element name=“plz” type=“PlzType”/>
    <xsd:element name=“city” type=“NameType”/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name=“FirmType”>
    xsd:sequence
    <xsd:element name=“fName” type=“xsd:string”/>
    <xsd:element name=“street” type=“NameType”/>
    <xsd:element name=“number” type=“NrType”/>
    <xsd:element name=“plz” type=“PlzType”/>
    <xsd:element name=“city” type=“NameType”/>
    <xsd:element name=“pBox” type=“PbType”/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name=“PNameType”>
    xsd:sequence
    <xsd:element name=“first” type=“NameType” minOccurs=“1”/>
    <xsd:element name=“last” type=“NameType” minOccurs=“1”/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name=“NameType”>
    <xsd:restriction base=“xsd:string”>
    <xsd:pattern value="[a-zA-Z


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 09:44 AM

    I guess you selected “addressList” as doctype before defining the schema to Tamino. For me the schema looks alright.
    I will move this question to the XQuery thread, because the XQuery people are listening there.

    P.S: Please attach your schema and instance and do not post it.


    #API-Management
    #webMethods
    #Tamino


  • 3.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 11:01 AM

    Hi,

    could you please give at least one query which delivers an unexpected result?

    Regards

    Harald


    #Tamino
    #webMethods
    #API-Management


  • 4.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 02:13 PM

    Sorry, no problem:

    for $a in input()/addressList/address
    return $a

    BTW I tested this just a minute ago with QuiP, getting the same results. But when I removed the namespaces in the first element (http://example.com/addressList) everything works exactly as expected.

    As you see the default namespace point to example.com, which is of course not the physical location of the file, that’s why the xsi:schemaLocation is in there pointing to a local file. QuiP still has problems with that, even if I replace the URI with valid webspace URI’s. I didn’t test this with Tamino though, as it is a bit more work than changing files in the file system. I’ll do that later today.

    Is there a problem with the treatment of namespaces?

    My doctype is btw addressList when working with the Tamino Schema editor.

    Thorsten


    #Tamino
    #API-Management
    #webMethods


  • 5.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 02:29 PM

    Perhaps in your query you forgot that all the elements in your source document are in a namespace, and that this namespace needs to be declared in the query?

    I’m only guessing, since you didn’t give an example of a query that fails or of the resulting error message.

    Michael Kay


    #Tamino
    #webMethods
    #API-Management


  • 6.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 06:03 PM

    You are probably right, nevertheless I cannot declare a namespace. Well, here is the query I used in QuiP

    First I tried this
    for $a in document(“instanz_test.xml”)/addressList/address
    return $a

    Without the namespaces the result document contains all addresses.
    With the namespaces the result is the following:

    <?xml version="1.0"?>
    <quip:result xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/” />

    Obviously there is no match in this case.

    That is the same in tamino, document() was replaced by input() and namespace declaration not removed, of course.

    So I tried to declare the namespace in the query, but it seems to me that I don’t get the syntax right, as I did not. I tried:

    import schema namespace addressList=“addressList”

    analogue to the Guided Tour examples in “XQuery from the experts”;
    tried different things, but they resulted in “XQuery parsing error”. I cannot find any documentation on declaring the namespace in a query, though. Checked the XQuery use-cases, specification and so on.

    What is sort of intriguing for me: Tamino does not show my instances in the Tamino X-plorer; for my other databases the instances are represented there. But these were started by DTDs transformed into schemas by the Tamino Schema Editor.

    Any more ideas?

    Thorsten


    #Tamino
    #API-Management
    #webMethods


  • 7.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 07:00 PM

    Hello Thorsten,

    I think that Michael is right - the namespace needs to be declared in the query.
    The following section in the Tamino documentation will help explain how to do this:

       .../Tamino 4.1.4.1/Documentation/xquery/xq-nutsnbolts.htm#xq-nb-prolog

    (Have a look in the same location of your installation, if you have a different version.)

    With the schema and document that you posted, the following query works for me:
        declare namespace ns=“http://example.com/addressList
        for $a in input()/ns:addressList/ns:address
        return $a

    Greetings,
    Trevor.


    #webMethods
    #Tamino
    #API-Management


  • 8.  RE: Importing XSchema into Tamino

    Posted Wed November 12, 2003 08:33 PM

    Thanks a million.That’s exactly what I needed.
    And I told my students that they had to take care of namespaces and of the correct path expressions…

    Hopefully they will never see this posting :slight_smile:

    Thorsten


    #API-Management
    #Tamino
    #webMethods