[relaxng-user] Pattern.

John Cowan cowan at mercury.ccil.org
Mon Nov 24 13:48:03 ICT 2003


David.Pawson at rnib.org.uk scripsit:

> I'm trying to find a pattern for the en-us attribute.

What you are trying to do is not possible.
You need to use a WXS pattern instead.

> <define name="LanguageCode">
>   <element name="languageCode">
>     <attribute name="lang">
>       <list>
> 	<ref name="PrimaryLang"/>
> 	<data type="string">
> 	  <param name="pattern">-</param>
> 	</data>
> 	<ref name="LangSubGroup"/>
>       </list>
>     </attribute>
>     <empty/>
>   </element>
> </define>

The list pattern can only cope with whitespace-separated items, not with
arbitrary concatenations.

In any case, the RFC 3066 language codes are an open set.  You should
either accept any arbitrary string of ASCII alphas, digits, and hyphen
(you can rule out initial, final, and consecutive hyphens if you like),
or else a fixed set of values that your application understands.

-- 
One art / There is                      John Cowan <jcowan at reutershealth.com>
No less / No more                       http://www.reutershealth.com
All things / To do                      http://www.ccil.org/~cowan
With sparks / Galore                     -- Douglas Hofstadter


More information about the relaxng-user mailing list