Jump to content

RobertB

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by RobertB

  1. Hi,Does anybody know of an easy way in a XSD to have a validation based on an attribute from the parent node ?My XML: .... <product no="218"> <part type="é" /> </product> <product no="205"> <participant>N</participant> <part type="é"> <nb>1</nb> </part> </product>...In the XSD:...<xs:element name="participant" minOccurs="0" maxOccurs="1">...<xs:element name="part" minOccurs="1" maxOccurs="12">The tag participant can only occur if the product no is 205, and the maxOccurs of product no 218 is 12 where is really is 10 for product no 205.How can I do this ? I really need both to be under the "product tag", so I cannot change its name.Thank's for help !
  2. 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>
  3. 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!
×
×
  • Create New...