Jump to content

including another schema


RobertB

Recommended Posts

Hi,I am new to XSD and cannot find how to do the following. I will have a bunch of XML documents that consist basically of 2 products. Th 1st product will vary in each XML doc but the second product (with all its restrictions) will always be the same.<?xml version="1.0" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="trxml"> <xs:complexType> <xs:sequence> <xs:element name="product1" minOccurs="1" maxOccurs="1"> <xs:complexType> <xs:restriction base="xs:string"> ...What I want here is to "include" the following without retype it every time: <xs:element name="product2" minOccurs="1" maxOccurs="1"> <xs:simpleType> <xs:restriction base="xs:string">I tried to xs:include the product2 but cannot find a way to make it work. :) Thank's for your help!

Link to comment
Share on other sites

I found a solution, thank's anyway !FYI, my solution is to assign a type for product2, to define that type in another xsd and to include it in the header of the main XML document. The product2 xml doc only contains the standard header plus the type definition:main XML doc:...<xs:element name="product2" maxOccurs="1" type="sel205Type" />...product2 XML doc:<?xml version="1.0" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:simpleType name="sel205Type"> <xs:restriction base="xs:string"> ... </xs:schema>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...