[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

XML pattern facets

Hello,

I'm trying to figure a pattern facet with my .xsd file. I want to only accept values that begin with 'E_ _' or 'N_ _' .

Right now I have the values under the enumeration a its looking for EEE or NNN, but I need to open it up to begins with E or N. I think I need to create a pattern facet but I'm unsure.

I'm having a hard time figuring out the syntax.

Also, if you have any references that I could use for syntax on these type of cases that would be great too.

Thanks
0
lulubell-b
Asked:
lulubell-b
  • 4
  • 3
3 Solutions
 
Geert BormansCommented:
assuming that you need a three letter word, starting with E or N, this is what you need (pattern facet indeed
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="foo" type="starts-with-E-or-N"/>
    <xs:simpleType name="starts-with-E-or-N">
        <xs:restriction base="xs:string">
            <xs:pattern value="E..|N.."></xs:pattern>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Open in new window

0
 
Geert BormansCommented:
staring with E or N and having any length would be
            <xs:pattern value="E.*|N.*"></xs:pattern>
or
            <xs:pattern value="(E|N).*"></xs:pattern>
0
 
lulubell-bAuthor Commented:
would this would work as well?


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="foo" type="starts-with-E-or-N"/>
    <xs:simpleType name="starts-with-E-or-N">
        <xs:restriction base="xs:string">
            <xs:pattern value="[EN][A-Z][A-Z]"></xs:pattern>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Geert BormansCommented:
yep, that is E or N as the first character and then 2 uppercase characters
if that is what you need, that would work as well
0
 
lulubell-bAuthor Commented:
Perfect thank you for the options
0
 
Geert BormansCommented:
welcome
0
 
lulubell-bAuthor Commented:
There many different solutions and that's why I like XML.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now