単純化の第8段階は <element>, <attribute> 要素の @name 属性の処理です。
- 対象ノードの箇所では接頭辞 "rng" は「RELAX NG 名前空間」に関連づけられているとします。
- サンプルでは見やすさのために空白や改行を入れているところがありますが、実際には単純化の第2段階で除去されています。
<element>, <attribute> 要素の @name 属性を <name> 要素に変更する
- 対象ノード
- //rng:element[@name]
//rng:attribute[@name] - 操作
- <name> 要素を付加し、その子テキストを @name 属性の値に設定する。 対象要素が <attribute> 要素で @ns 要素を持っていなければ、付加した <name> 要素に属性 ns="" を付加する。
サンプル1
まずは通常のサンプル:
<element name="an-element"> <empty/> </element>
<element> <name>an-element</name> <empty/> </element>
サンプル2
次は、@ns 属性のない <attribute> 要素の例:
<attribute name="an-attribute"/>
<attribute> <name ns="">an-attribute</name> </attribute>