Hi Lawrence,

 

Thank you for the e-mail.  Is it possible to have a XML instance that looks like the following?

 

<?xml version="1.0" encoding="UTF-8"?>

<ResponseBatch xmlns="http://infor.com/FactsResponseBatch"

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                          ConsumerKey="1234"

                          Language="English"

                         DateTime="today"

                         SerialID="0011111">

    <Response xmlns:tns="http://infor.com/FactsItemBalance" RequestID="ItemBalance" SerialID="54321" Company="12">

        <Warehouses>

            <Warehouse>

                <WarehouseId>Warehouse 1</WarehouseId>

                <Items>

                    <Item>

                        <ItemNumber>Item Number 1</ItemNumber>

                        <ListPrice1>1.5</ListPrice1>

                        <ListPrice2>2.5</ListPrice2>

                        <ListPrice3>3.5</ListPrice3>

                        <ListPrice4>4.5</ListPrice4>

                        <ListPrice5>5.5</ListPrice5>

                        <QuantityOnHand>99.9</QuantityOnHand>

                        <SuspendFlag>Y</SuspendFlag>

                    </Item>

                </Items>

            </Warehouse>

        </Warehouses

    </Response>

  <Response xmlns:tns="http://infor.com/FactsItemReplacement" RequestID="CustomerItemReplacement" SerialID="54321" Company="12">

      <Warehouses>

            <Warehouse>

                <WarehouseId>Warehouse 1</WarehouseId>

                <Items>

                    <Item>

                        <ItemNumber>Item Number 1</ItemNumber>

                    </Item>

                </Items>

            </Warehouse>

        </Warehouses>

   </Response>

</ResponseBatch>

 

All the nodes inside the Response level will be the same except inside the Item element.  Here is the XSD I have so far:

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema

    targetNamespace="http://infor.com/FactsResponseBatch"

    elementFormDefault="qualified"

    xmlns:cd="http://infor.com/FactsCodeData"

    xmlns:rs="http://infor.com/FactsItemBalance"

    xmlns:xs="http://www.w3.org/2001/XMLSchema">

 

    <xs:import namespace="http://infor.com/FactsItemBalance"

            schemaLocation="ItemBalance.xsd"/>

    <xs:import namespace="http://infor.com/FactsCodeData"

            schemaLocation="CodeData.xsd"/>

 

    <xs:element name="ResponseBatch">

        <xs:complexType>

            <xs:choice maxOccurs="unbounded">

                <xs:element name="Response"    type="rs:Response"/>

                <xs:element name="Response"    type="cd:Response"/>

 

            </xs:choice>

                  <xs:attribute name="ConsumerKey" type="xs:string"/>

                  <xs:attribute name="Language" type="xs:string"/>

                  <xs:attribute name="DateTime" type="xs:string"/>

                  <xs:attribute name="SerialID" type="xs:string"/>

        </xs:complexType>

    </xs:element>

</xs:schema>

 

When I try to create the jar file it complains that the response element already exists.  Any clues?

 

Thanks,

 

Richard Butterwood | Senior Analyst/Programmer | Infor | office: 770-418-2000 X 1167 | cell: 678-492-3080 | fax: 770-418-2022 | [EMAIL PROTECTED]


From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 21, 2005 3:13 PM
To: [email protected]
Subject: RE: Multiple Namespaces in an XSD with XML Beans

 

Hi Richard

 

What you want is fine and is supported. However, in your instance doc declaring the attribute xmlns:tns="http://infor.com/FactsCodeData" in your Response element does nothing other than map the prefix tns to the namespace http://infor.com/FactsCodeData. It does not change the namespace of the Response element or any of its children. Instead, as it stands, those elements will inherit the default namespace “http://infor.com/FactsResponseBatch” from the xmlns=”…” attribute in its parent ResponseBatch element.

 

I believe what you want is xmlns="http://infor.com/FactsCodeData". This will override the default namespace from the parent ResponseBatch element and make the namespace “http://infor.com/FactsCodeData” for Response and all its children. Alternatively you can keep the tns prefix declaration and use the tns prefix on the Response element and all its children i.e. <tns:Response …> <tns:Codes> … </tns:Codes> </tns:Response>.

 

In order to set up the schema to match this you need 2 schemas – 1 with targetNamespace="http://infor.com/FactsResponseBatch", and 1 with targetNamespace="http://infor.com/FactsCodeData". The first schema should define the ResponseBatch element and import the second schema. The second schema should define Response and all its children.

 

Cheers,

 

Lawrence

 


From: Butterwood, Richard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 21, 2005 11:11 AM
To: [email protected]
Subject: Multiple Namespaces in an XSD with XML Beans

 

Merry Christmas!

 

I would like my XML instance file to look like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<ResponseBatch xmlns="http://infor.com/FactsResponseBatch"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           ConsumerKey="1234"

               Language="English"

               DateTime="today"

                     SerialID="0011111">

    <Response xmlns:tns="http://infor.com/FactsCodeData"

                          RequestID="CodeData" SerialID="54321" Company="12">

        <Codes>

                        <Code>

                      <Code>Code Value </Code>

                      <Description>Description Value</Description>

                      <ParentCode>Parent Code Value</ParentCode>

                        </Code>

        </Codes>

              <RestartPoint>abcdefg</RestartPoint>

    </Response>

</ResponseBatch>

 

In other words I want the namespace xmlns:tns="http://infor.com/FactsCodeData" to cover only response elements and its sub-elements.  I want the ResponseBatch top element to have its own name space.  Here is the XSD so far:

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema

    targetNamespace="http://infor.com/FactsResponseBatch"

    elementFormDefault="qualified"

    xmlns:rns="http://infor.com/FactsResponseBatch"

    xmlns:tns="http://infor.com/FactsCodeData"

    xmlns:xs="http://www.w3.org/2001/XMLSchema">

 

    <xs:element name="ResponseBatch">

        <xs:complexType>

            <xs:choice maxOccurs="unbounded">

                <xs:element name="Response"    type="tns:Response"/>

            </xs:choice>

                                    <xs:attribute name="ConsumerKey" type="xs:string"/>

                                    <xs:attribute name="Language" type="xs:string"/>

                              <xs:attribute name="DateTime" type="xs:string"/>

                              <xs:attribute name="SerialID" type="xs:string"/>

        </xs:complexType>

    </xs:element>

 

  <xs:complexType name="Response">

        <xs:sequence>

            <xs:element name="Codes" type="tns:Codes"/>

            <xs:element name="RestartPoint" type="xs:string"/>

        </xs:sequence>

            <xs:attribute name="RequestID" type="xs:string"/>

      <xs:attribute name="Company" type="xs:int"/>

      <xs:attribute name="SerialID" type="xs:string"/>

  </xs:complexType>

 

  <xs:complexType name="Codes">

        <xs:sequence>

            <xs:choice maxOccurs="unbounded">

                <xs:element name="Code" type="tns:Code"/>

            </xs:choice>

        </xs:sequence>

  </xs:complexType>

 

  <xs:complexType name="Code">

        <xs:sequence>

            <xs:element name="Code" type="xs:string"/>

            <xs:element name="Description" type="xs:string"/>

            <xs:element name="ParentCode" type="xs:string"/>

        </xs:sequence>

  </xs:complexType>

 

</xs:schema>

 

 

Is this possible with XML Beans? 

 

 

Richard Butterwood | Senior Analyst/Programmer | Infor | office: 770-418-2000 X 1167 | cell: 678-492-3080 | fax: 770-418-2022 | [EMAIL PROTECTED]

 

SAVE THE DATE:
Inforum
Infor Customer Conference
April 9 – 12, 2006
Mandalay Bay Resort & Casino
Las Vegas

 

Reply via email to