[xsl] Restricting Element Order with Attribute Values

Subject: [xsl] Restricting Element Order with Attribute Values
From: Rudi Starcevic <tech@xxxxxxxxxxxx>
Date: Tue, 27 Sep 2005 00:07:14 +1000
Hi,

Is it possible to restrict elements based upon the order of element
attributes?

For example can I restrict
<server dn="myserver.com" id="server392" ip="xxx.xx.xxx.xxx">
<webstats uri="myserver.com/webalizer" type="http"/>
<webstats uri="myserver.com/bandwidth" type="bytes"/>
</server>

So I can say one cannot have a <webstats type='bytes'/> without first having
a <webstats type='http'/>

<xs:complexType name="webstatsType">
    <xs:attribute name="type">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <!-- <xs:pattern value="http|bytes"></xs:pattern> -->
                <xs:enumeration value="http"/>
                <xs:enumeration value="bytes"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="uri" type="xs:anyURI"></xs:attribute>
    <xs:attribute name="username" type="xs:string"></xs:attribute>
    <xs:attribute name="pwd" type="xs:string"></xs:attribute>
</xs:complexType>  

Or should I not be using attributes for this type restriction and have
<bytes> elements
inside <http> elements?

I'm thinking if I can restrict the order of these elements in my xsd
files I can use
less <xsl:if> in my xsl files when sorting the different types
of web statistics available for each web site inside each server.

Thanks.
Regards,
Rudi.

Current Thread