The extention syntax propertyName
specifies a property name
for a property.
A target of the default
attribute is the property.
The propertyName
attribute takes a string value
for a property name of a target property.
A property name for a target property will be the name specified by
the propertyName
attribute.
List 8.4.4.1[grammarPropertyName.rng] is a sample schema
that uses the propertyName attribute.
In element
elements named balance
and owner
,
the className attributes is used.
In this case, a name of a property from the element balance
will be
amount
instead of balance
, and
the name of the property from the element owner
will be
person
instead of owner
.
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:java="http://www.relaxer.org/xmlns/relaxer/java" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <ref name="account"/> </start> <define name="account"> <element name="account"> <attribute name="accountNo"> <data type="token"/> </attribute> <element name="balance" java:propertyName="amount"> <data type="int"/> </element> <element name="owner" java:propertyName="person"> <data type="token"/> </element> <ref name="address"/> <zeroOrMore> <ref name="phone"/> </zeroOrMore> </element> </define> <define name="address"> <element name="address"> <attribute name="zip"> <data type="token"/> </attribute> <text/> </element> </define> <define name="phone"> <element name="phone"> <attribute name="area"> <data type="token"/> </attribute> <data type="token"/> </element> </define> </grammar>
Effects of the propertyName attribute on the sample schema are described in Table 8.4.4.1[Effects of Property Name].
element name | with propertyName | without propertyName |
---|---|---|
accountNo | accountNo | accountNo |
balance | amount | balance |
person | person | owner |
address | address | address |
phone | phone | phone |