|
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, From: Butterwood,
Richard [mailto:[EMAIL PROTECTED] 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: |
- Multiple Namespaces in an XSD with XML Beans Butterwood, Richard
- Re: Multiple Namespaces in an XSD with XML Beans Alistair Young
- RE: Multiple Namespaces in an XSD with XML Beans Lawrence Jones
- RE: Multiple Namespaces in an XSD with XML Beans Butterwood, Richard

