You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Butterwood, Richard" <Ri...@infor.com> on 2005/12/21 20:11:13 UTC

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 |
richard.butterwood@infor.com

 

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

 


Re: Multiple Namespaces in an XSD with XML Beans

Posted by Alistair Young <al...@smo.uhi.ac.uk>.
Richard,

I used this sort of thing recently. The top level doc and all it's schema
children had their own namespace:

urn:oasis:names:tc:SAML:2.0:metadata

with one specific child element having a different namespace:

urn:guanxi:metadata

I defined the urn:guanxi:metadata ns in it's own xsd and imported the
"root" ns:

<schema
  targetNamespace="urn:guanxi:metadata"
  xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
        xmlns:gxmeta="urn:guanxi:metadata"
        elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  blockDefault="substitution"
  version="2.0">

        <import namespace="urn:oasis:names:tc:SAML:2.0:metadata"
schemaLocation="saml/saml-schema-metadata-2.0.xsd"/>

...

<complexType name="attributeServiceExtensionsType">
    <sequence>
      <element name="Location" type="string"/>
    </sequence>
  </complexType>
  <element name="GuanxiAttributeAuthority"
type="gxmeta:attributeServiceExtensionsType" />

...

</schema>

You can then get at the urn:guanxi:metadata ns via the root ns beans. You
just break out into w3c from the urn:oasis:names:tc:SAML:2.0:metadata
beans and give the node to the urn:guanxi:metadata beans.

hope this helps,

Alistair


-- 
Alistair Young
Senior Software Engineer
UHI@Sabhal Mòr Ostaig
Isle of Skye
Scotland

> 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 |
> richard.butterwood@infor.com
>
>
>
> SAVE THE DATE:
> Inforum
> Infor Customer Conference
> April 9 - 12, 2006
> Mandalay Bay Resort & Casino
> Las Vegas
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org