Re: [xsl] Schema restriction between attributes

Subject: Re: [xsl] Schema restriction between attributes
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: 31 May 2003 06:53:16 +0100
>>>>> "Eran" == Eran Hammer-Lahav <xalan@xxxxxxxxx> writes:

    Eran> Is there a way in a schema to specify restrictions on one
    Eran> attribute if another has a certain value? Here is an
    Eran> example:

    Eran> <?xml version="1.0" ?> <xs:schema id="x" targetNamespace="x"
    Eran> xmlns:x="x" xmlns:xs="";
    Eran> version="1.0"> <xs:element name="structure">
    Eran> <xs:complexType> <xs:sequence> <xs:element name="field"
    Eran> minOccurs="0" maxOccurs="unbounded"> <xs:complexType>
    Eran> <xs:attribute name="name" type="xs:string" use="required" />
    Eran> <xs:attribute name="type" type="omm:memberType"
    Eran> use="required" /> <xs:attribute name="typeName"
    Eran> type="xs:string" use="optional" /> </xs:complexType>
    Eran> </xs:element> </xs:sequence> <xs:attribute name="class"
    Eran> type="xs:string" use="required" /> <xs:attribute
    Eran> name="dbTable" type="xs:string" use="required" />
    Eran> </xs:complexType> </xs:element> </xs:schema>

    Eran> I want that if structure/@type = 'enum', structure/@typeName
    Eran> will not be empty. Is there a way to achieve this in the
    Eran> schema? I know I can do this in the xslt script, by check
    Eran> each value and using the <xsl:message> message to end
    Eran> execution, but I would like to have the schema control this.

You can do this by embedding Schematron rules within the schema.

Colin Paul Adams
Preston Lancashire

 XSL-List info and archive:

Current Thread