• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • 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 BormansInformation ArchitectCommented:
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 BormansInformation ArchitectCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Geert BormansInformation ArchitectCommented:
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 BormansInformation ArchitectCommented:
welcome
0
 
lulubell-bAuthor Commented:
There many different solutions and that's why I like XML.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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