• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

Restrict attibute values using xs:pattern and regular expresions

Hello guys,
I need to check using xsd, that the attribute of a node is something like <name>\flex\<fileName>.flex.plugin

I have made the xsd below where i use the regular expression
[a-z]*\\flex\\[a-z]*.flex\.(plugin)$

But this does not work and i cannot figure out why and how to do it correct.
Any help is highly appreciated.
<xs:element name="myplugin">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="url" type="plugin:urlType" use="required"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="urlType">
    	<xs:restriction base="xs:string">
    	 <xs:pattern value="[a-z]*\\flex\\[a-z]*.flex\.(plugin)$"></xs:pattern>
    	</xs:restriction>
    </xs:simpleType>

Open in new window

0
Rongas
Asked:
Rongas
  • 2
  • 2
1 Solution
 
Geert BormansInformation ArchitectCommented:
< and > are not in [a-z]
it seems like you need a pattern like this

if this doesn't work, please send some real XML examples
&lt;[a-z]*&gt;\\flex\\&lt;[a-z]*&gt;\.flex\.plugin$

Open in new window

0
 
RongasAuthor Commented:
I still have problems. Also i am not sure if i got correct the regular expression you gave me. i attach example of what i need/done in the txt attached.

also, if it is easy for you, can you also make regular expression you provide to let me have also '-' character allowed?
cheers.
examples.txt
0
 
Geert BormansInformation ArchitectCommented:
ah, you don't need the <> after all, it is just your mask of the file path
made your question very confusing by the way

Here is the pattern I would use
    <xs:simpleType name="urlType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z0-9\-]*\\flex\\([a-zA-Z0-9\-]+\.)+plugin"></xs:pattern>
        </xs:restriction>
    </xs:simpleType>

Open in new window

0
 
RongasAuthor Commented:
increasing points due to agreeing that question and way of asking the question deserved more points.
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

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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