How do I make a valid inline XML schema?

Ashley

New Member
I need to author an embedded XML schema, i.e. where the schema is define within the same XML as the data.I'm trying to understand how to do it correctly, but so far I'm failing to get a simple example to pass validation. Here's what I was trying to use as a trivial example XML with inline schema:
(Note: The XML structure (e.g. root/item) is already out in the wild so I am constrained to not be able to use a namespace on the data elements.)\[code\]<?xml version="1.0"?><root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#mySchema"> <xs:schema id="mySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="item" type="xs:string" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> <item>String 1</item> <item>String 2</item> <item>String 3</item></root>\[/code\]But when I run that XML through the w3.org http://www.w3.org/2001/03/webdata/xsv}:schema not allowed here (1) in element {None}:root, expecting [{None}:item,$]:\[/quote\]Q: Can you show me an example of a simple XML document with inline schema definition that passes validation?
 
Back
Top