lundi 14 décembre 2015

Passing pattern value as parameter or reference dynamic

I want to enforce my ID/IDRefs with a pattern. The code below works perfectly, but i would like to optimize it a bit, because all the different types are the same except for the first 3 characters in the pattern. Is it possible to have a generic type, which takes the prefix (SEG, ITI, ...) as a parameter ?

Thank you

<xsd:complexType name="SegmentIDRefs">
    <xsd:complexContent>
        <xsd:restriction base="common:IDRefs">
            <xsd:attribute name="Id">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:ID">
                        <xsd:pattern value="SEG_[\da-fA-F]{8}"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
            <xsd:attribute name="GUID" type="common:external.GUID"/>
            <xsd:attribute name="RefId">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:IDREF">
                        <xsd:pattern value="SEG_[\da-fA-F]{8}"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="ItineraryIDRefs">
    <xsd:complexContent>
        <xsd:restriction base="common:IDRefs">
            <xsd:attribute name="Id">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:ID">
                        <xsd:pattern value="ITI_[\da-fA-F]{8}"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
            <xsd:attribute name="GUID" type="common:external.GUID"/>
            <xsd:attribute name="RefId">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:IDREF">
                        <xsd:pattern value="ITI_[\da-fA-F]{8}"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>

Aucun commentaire:

Enregistrer un commentaire