473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

validate element with attribute xsi:type="xsd:string"

How do you validate the following XML document, I'm having problems
with element 'one' with the attribute xsi:type="xsd:string"

<?xml version="1.0" encoding="UTF-8"?>
<zero xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<one xsi:type="xsd:string">test</one>
</zero>

Jul 20 '05 #1
8 3417


jo******@gmail.com wrote:
How do you validate the following XML document, I'm having problems
with element 'one' with the attribute xsi:type="xsd:string"

<?xml version="1.0" encoding="UTF-8"?>
<zero xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<one xsi:type="xsd:string">test</one>
</zero>


To validate you need a schema I think, I don't know any validators
checking the xsi:type attribute alone.
And of course you need to bind the prefix xsd e.g.
<zero
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
I've been working with the following schema without luck.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

<xsd:element name="zero">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="one" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="one" type="xsd:string"/>

<xsd:complexType name="xsd:string">
<xsd:simpleContent>
<xsd:extension base="xsd:string"/>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>

Jul 20 '05 #3


jo******@gmail.com wrote:
I've been working with the following schema without luck.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

<xsd:element name="zero">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="one" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="one" type="xsd:string"/>

<xsd:complexType name="xsd:string">
<xsd:simpleContent>
<xsd:extension base="xsd:string"/>
</xsd:simpleContent>
</xsd:complexType>


Why are you trying to redefine xsd:string then?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
I'm trying to write a schema to validate the xml document, and I dont
know how to handle the one element. Based on the following I came up
with the previous schema.

<?xml version="1.0" encoding="UTF-8"?>
<zero xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<one xsi:type="A">test</one>
</fullName>

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

<xsd:element name="zero">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="one" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="one" type="A"/>

<xsd:complexType name="A">
<xsd:simpleContent>
<xsd:extension base="xsd:string"/>
</xsd:simpleContent>
</xsd:complexType>

</xsd:schema>

Jul 20 '05 #5


jo******@gmail.com wrote:
I'm trying to write a schema to validate the xml document, and I dont
know how to handle the one element.


The schema is simple but you need to bind the prefix xsd as already
explained:

<?xml version="1.0" encoding="UTF-8"?>
<zero xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test2005060801Xsd.x ml"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<one xsi:type="xsd:string">test</one>
</zero>

then the schema looks as

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

<xs:element name="zero">
<xs:complexType>
<xs:sequence>
<xs:element name="one" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #6
Thanks!

Jul 20 '05 #7
If you could help me out with more more thing that would be great, you
have been very helpful.

Again trying to build a schema based on the following XML. I
understand how to describe the 'one' element I dont understand how to
describe the soap message within the schema.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>

<one xsi:type="xsd:string>test</one>

</soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
version="1.0">

<xsd:element name="zero">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="one" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>

Thanks in advance.

Jul 20 '05 #8


jo******@gmail.com wrote:
If you could help me out with more more thing that would be great, you
have been very helpful.

Again trying to build a schema based on the following XML. I
understand how to describe the 'one' element I dont understand how to
describe the soap message within the schema.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>

<one xsi:type="xsd:string>test</one>

</soapenv:Body>
</soapenv:Envelope>


You need to have two schemas then as one schema can only describe the
elements in one particular target namespace while your XML instance
above has elements in the namespace
http://schemas.xmlsoap.org/soap/envelope/ and in no namespace.

So a possible solution is

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
version="1.0">

<xs:import schemaLocation="test2005060902Xsd.xml" />

<xs:element name="Envelope">
<xs:complexType>
<xs:sequence>
<xs:element name="Body">
<xs:complexType>
<xs:sequence>
<xs:element ref="one" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

where the imported schema test2005060902Xsd.xml is

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

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

</xs:schema>

and the instance is

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
test2005060901XSd.xml">
<soapenv:Body>
<one xsi:type="xsd:string">test</one>
</soapenv:Body>
</soapenv:Envelope>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ulf Heyder | last post by:
Hello, I have to deal with some xml schemas from a third party. This schema contains the following complex type. <?xml version="1.0"?> <xsd:schema ... elementFormDefault="qualified"> .......
2
by: linkspeed | last post by:
Hi, I tried following element definition in MSXML 4.0 <xsd:element name="Identifier"> <xsd:simpleType> <xsd:restriction base="xsd:token"> <xsd:pattern value=".*"/> </xsd:restriction>...
0
by: johnsocs | last post by:
All I'm trying to write an xml schema for the following xml from the google web service api. In the schema I'm not sure how to describe the soapenv:encodingStyle attribute. Thanks. <?xml...
1
by: comic_rage | last post by:
Hi, I am writing C# code to produce xml schema. //Create attribute XmlSchemaAttribute att2 = new XmlSchemaAttribute(); att2.Name = "CustomerID"; att2.SchemaTypeName = new...
0
by: Andrew Burgher | last post by:
Feeding the following .xsd into the XsdObjectGen (v1.4.2.0) tool produces an invalid attribute: with DataType="System.String". Has anybody seen this behaviour before? Is this a bug in...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
0
by: Kaimar Seljamäe | last post by:
Hi, I have to create a web service client which uses SOAP encoding but does not use "multi-reference" values (see http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383513 item 10). If I...
6
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new...
4
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.