Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XML Schema regular expression validation

Raj__KNov 8 2019 — edited Nov 11 2019

Hi XML Experts,

Please let me know whether a regular expression be used to validate the duplicate values in a xml element. The xml element can have comma seperated value from a list of values.

If it is feasible, please share a pattern.

   

Sample xsd   

    <schema targetNamespace="http://www.xyz.com/xyz"

        xmlns="http://www.w3.org/2001/XMLSchema"

        xmlns:x="http://www.xyz.com/xyz"

        elementFormDefault="qualified">

        <element name="CompanyDetails">

            <complexType>

                <sequence>

                    <element name="CountryList" type="x:CountryListType"/>

                </sequence>

            </complexType>

        </element>

        <simpleType name="CountryListType">

            <restriction base="string">

                <pattern value="France|Germany|India"/>

            </restriction>

        </simpleType>

    </schema>   

   

Sample xml

    <CompanyDetails>

        <CountryList>France,Germany,India</CountryList>

    </CompanyDetails>

For example in the CountryList xml element if there is a duplicate entry then the validation need to fail.

    <CountryList>France,Germany,India,Germany</CountryList>

Thank You!

Comments
Post Details
Added on Nov 8 2019
3 comments
1,492 views