Hi Dave,
Le lundi 12 septembre 2005 à 15:09 +0100, Dave Pawson a écrit :
> html has an img element,
> the height attribute can be either 
> 
> 128 or 60%
> 
> How do I specify this in rng please?
> 
>  <attribute name="height"> 
>    <choice>
>      <data type="positiveInteger"/>
>      <group>
>        <data type="positiveInteger"/>
>        <value>%</value>
>      </group>
>    </choice>
>  </attribute> 

No, you can't write :

     <group>
       <data type="positiveInteger"/>
      <value>%</value>
     </group>

Each of the "data" or "value" patterns takes a text node (or attribute
value) as a whole...

> isn't working. I want a positive integer, with the 'units' (%).

The closest you can do following this principle, if your value and unit
are separated by a whitespace, is to use a list pattern to split your
text:

            <attribute name="height">
                <list>
                    <data type="positiveInteger"/>
                    <optional>
                        <value>%</value>
                    </optional>
                </list>
            </attribute>

or

   attribute height {
      list { xsd:positiveInteger, "%"? }
    }

That would validate "3", "3 %"" but not "3%".

If you really need to validate "3%", you bust use a token and a pattern
facet:

    attribute height {
      xsd:token {pattern ="[0-9]+%?"}
    }

or

      <attribute name="height">
        <data type="token">
          <param name="pattern">[0-9]+%?</param>
        </data>
      </attribute>

the downside is that you loose the semantics of saying that you want a
value followed by a unit...

Hope this helps.

Eric

> 
> James's xhtml shows
> 
> # nn for pixels or nn% for 
> Length.datatype = text
> 
> Does that means its a no no?
> 
> 
> 
> 
-- 
Lisez-moi sur XMLfr.
                       http://xmlfr.org/index/person/eric+van+der+vlist/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/2U_rlB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/rng-users/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to