Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Need help with this schema

From: "Jeremy Chapman" <please@------------->
To: NULL
Date: 8/4/2006 10:06:00 AM

Thanks for the tip about mixed elements, that's exactly what I needed. 
Regarding the namespaces, my problem is that the xml is generated by a 3rd 
party app, and I'm trying to create an xsd basically to document for our 
purposes what the xml would look like.  Unfortunately the root node has a 
namespace and prefix (<ns0:Assessment xmlns:ns0="http://AIM.xsd">)  but non 
of the child elements do. Any way to get this to validate with a schema?

"George Bina" <george@o...> wrote in message 
news:1154505542.754439.68980@h......
> Hi Jeremy,
>
> To allow both elements and text content in an element add mixed="true"
> to the complex type for that element. Note that you have placed
> incorrectly all the elements except the root element in no namespace
> instead of schema target namespace. You can find below a corrected
> instance and an updated schema to allow mixed content in all the
> elements that contain mixed content in the sample instance document.
>
> <Assessment xmlns="http://AIM.xsd">
>    <Location>ABC</Location>
>    <Client>1234A</Client>
>    <Client_Name>FRED SMITH</Client_Name>
>    <Address>123 St, City Prov</Address>
>    <City>CityName</City>
>    <Province>AB</Province>
>    <Postal_Code>LNL NLN</Postal_Code>
>    <Telephone>555-555-5555</Telephone>
>    <System>Assessment</System>
>    <Type>Assessment</Type>
>    <Date>28 JUN 06</Date>
>    <Completed_By>UserName</Completed_By> Additional Text
>    <Section Value="AA"> Additional text
>        <Question Value="1.A"> Question text
>            <Question_Text>Question text</Question_Text>
>            <Answer_Text>Answer</Answer_Text>
>            <Answer_Value>1</Answer_Value>
>        </Question>
>        <Question Value="1.B"> Question text
>            <Question_Text>Question text</Question_Text>
>            <Answer_Text>Answer</Answer_Text>
>            <Answer_Value>1</Answer_Value>
>        </Question>
>    </Section>
>    <Section Value="CC"> Referral Items
>        <Question Value="1"> Question text
>            <Question_Text>Question text</Question_Text>
>            <Answer_Text>Answer</Answer_Text>
>            <Answer_Value>1</Answer_Value>
>        </Question>
>    </Section>
> </Assessment>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:ns0="http://AIM.xsd"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://AIM.xsd"
>  elementFormDefault="qualified" attributeFormDefault="unqualified">
>  <xs:element name="Assessment">
>    <xs:complexType mixed="true">
>      <xs:sequence>
>        <xs:element name="Location" type="xs:string"/>
>        <xs:element name="Client" type="xs:string"/>
>        <xs:element name="Client_Name" type="xs:string"/>
>        <xs:element name="Address" type="xs:string"/>
>        <xs:element name="City" type="xs:string"/>
>        <xs:element name="Province" type="xs:string"/>
>        <xs:element name="Postal_Code" type="xs:string"/>
>        <xs:element name="Telephone" type="xs:string"/>
>        <xs:element name="System" type="xs:string"/>
>        <xs:element name="Type" type="xs:string"/>
>        <xs:element name="Date" type="xs:string"/>
>        <xs:element name="Completed_By" type="xs:string"/>
>        <xs:element name="Section" maxOccurs="unbounded">
>          <xs:complexType mixed="true">
>            <xs:sequence>
>              <xs:element name="Question" maxOccurs="unbounded">
>                <xs:complexType mixed="true">
>                  <xs:sequence>
>                    <xs:element name="Question_Text" type="xs:string"/>
>                    <xs:element name="Answer_Text" type="xs:string"/>
>                    <xs:element name="Answer_Value" type="xs:string"/>
>                  </xs:sequence>
>                  <xs:attribute name="Value" type="xs:string"
> use="required"/>
>                </xs:complexType>
>              </xs:element>
>            </xs:sequence>
>            <xs:attribute name="Value" type="xs:string"
> use="required"/>
>          </xs:complexType>
>        </xs:element>
>      </xs:sequence>
>    </xs:complexType>
>  </xs:element>
> </xs:schema>
>
>
> Best Regards,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> www.---.com
>
> Jeremy Chapman wrote:
>> I've got the following xml, and I'm trying to develop an xsd (below) to
>> validate it. For the most part, my xsd is good, except I am having 
>> trouble
>> accomodating the text after the Completed_By tag.  How can I do this?
>>
>> <ns0:Assessment xmlns:ns0="http://AIM.xsd">
>>     <Location>ABC</Location>
>>     <Client>1234A</Client>
>>     <Client_Name>FRED SMITH</Client_Name>
>>     <Address>123 St, City Prov</Address>
>>     <City>CityName</City>
>>     <Province>AB</Province>
>>     <Postal_Code>LNL NLN</Postal_Code>
>>     <Telephone>555-555-5555</Telephone>
>>     <System>Assessment</System>
>>     <Type>Assessment</Type>
>>     <Date>28 JUN 06</Date>
>>     <Completed_By>UserName</Completed_By> Additional Text
>>     <Section Value="AA"> Additional text
>>         <Question Value="1.A"> Question text
>>             <Question_Text>Question text</Question_Text>
>>             <Answer_Text>Answer</Answer_Text>
>>             <Answer_Value>1</Answer_Value>
>>         </Question>
>>         <Question Value="1.B"> Question text
>>             <Question_Text>Question text</Question_Text>
>>             <Answer_Text>Answer</Answer_Text>
>>             <Answer_Value>1</Answer_Value>
>>         </Question>
>>      </Section>
>>      <Section Value="CC"> Referral Items
>>         <Question Value="1"> Question text
>>             <Question_Text>Question text</Question_Text>
>>             <Answer_Text>Answer</Answer_Text>
>>             <Answer_Value>1</Answer_Value>
>>         </Question>
>>     </Section>
>> </ns0:Assessment>
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema xmlns:ns0="http://AIM.xsd"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>> targetNamespace="http://AIM.xsd"
>> elementFormDefault="qualified" attributeFormDefault="unqualified">
>>  <xs:element name="Assessment">
>>   <xs:complexType>
>>    <xs:sequence>
>>     <xs:element name="Location" type="xs:string"/>
>>     <xs:element name="Client" type="xs:string"/>
>>     <xs:element name="Client_Name" type="xs:string"/>
>>     <xs:element name="Address" type="xs:string"/>
>>     <xs:element name="City" type="xs:string"/>
>>     <xs:element name="Province" type="xs:string"/>
>>     <xs:element name="Postal_Code" type="xs:string"/>
>>     <xs:element name="Telephone" type="xs:string"/>
>>     <xs:element name="System" type="xs:string"/>
>>     <xs:element name="Type" type="xs:string"/>
>>     <xs:element name="Date" type="xs:string"/>
>>     <xs:element name="Completed_By" type="xs:string"/>
>>     <xs:element name="Section" maxOccurs="unbounded">
>>      <xs:complexType>
>>       <xs:sequence>
>>        <xs:element name="Question" maxOccurs="unbounded">
>>         <xs:complexType>
>>          <xs:sequence>
>>           <xs:element name="Question_Text" type="xs:string"/>
>>           <xs:element name="Answer_Text" type="xs:string"/>
>>           <xs:element name="Answer_Value" type="xs:string"/>
>>          </xs:sequence>
>>          <xs:attribute name="Value" type="xs:string" use="required"/>
>>         </xs:complexType>
>>        </xs:element>
>>       </xs:sequence>
>>       <xs:attribute name="Value" type="xs:string" use="required"/>
>>      </xs:complexType>
>>     </xs:element>
>>    </xs:sequence>
>>   </xs:complexType>
>>  </xs:element>
>> </xs:schema>
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent