Reputation: 97
I am using Relax Ng
to validate XML
file
In my XML file I have a tag with several values separated by comma
<mytage>01,02,03,04<mytage>
I can use <List>
pattern in the .rng file but it matches a whitespace-separated sequence not comma-separated
Upvotes: 2
Views: 142
Reputation: 88066
It could be specified using <param name="pattern">
with a regular expression; for example:
<data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<param name="pattern">[0-9][0-9](,[0-9][0-9])*</param>
</data>
Or in the compact syntax:
xsd:string {
pattern = "[0-9][0-9](,[0-9][0-9])*"
}
If you want to make it part of a <choice>
:
<choice>
<data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<param name="pattern">[0-9][0-9](,[0-9][0-9])*</param>
</data>
<data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<param name="pattern">…</param>
</data>
</choice>
Or in the compact syntax:
( xsd:string {
pattern = "[0-9][0-9](,[0-9][0-9])*"
}
| xsd:string {
pattern = "…"
}
)
Upvotes: 1