M
McSwell
I have written an XML schema using RNG, and some XML docs that
(according to xmllint) conform to that schema. I noticed recently
that I did something odd, and I'm surprised that xmllint hasn't
complained. The oddity is similar to what, in object oriented
programming circles, is called "overloading".
Specifically, I have two different element definitions in the same
namespace that use the same name. There's maybe a good reason for
that; one of them defines an object, assigning it an ID, while the
other points to the defined object using an IDREF.
Here's an example. First the parts of the schema, simplified:
<define name="TerminalUnitType" combine="choice">
<ref name="Phoneme"/> <!--Defined below-->
</define>
<define name="TerminalUnitType" combine="choice">
<ref name="Grapheme"/> <!--Defined below-->
</define>
... (more TerminalUnitType defns)...
<define name="Phoneme" combine="choice">
<element name="Phoneme">
...define some attrs, including id...
</element>
</define>
...
<define name="Ref2Phoneme" combine="choice">
<element name="Phoneme">
<attribute name="idref"/>
</element>
</define>
Notice that I've defined the element "Phoneme" twice: the first time
with an id (and some other stuff, not shown), and the second time with
an idref. The XML doc follows this; there are instances of Phonemes
that have the id etc.:
<Phhoneme id="phDDA" spelling="\u09A1"/>
and there are instances of Phonemes that have just the idref:
<Phhoneme idref="phDDA"/>
How did I get away with this? Is it because I used <define
name="TerminalUnitType" combine="choice">? (Looking back, I'm not
sure that defining the TerminalUnitType bought me anything.)
And is it a Bad Idea to define the name twice? Conceptually, both
indeed represent phonemes, although I'm thinking maybe I should call
the first one (the one with the 'id' attr) "PhonemeDefinition" instead
of "Phoneme".
Thoughts?
Mike Maxwell
(according to xmllint) conform to that schema. I noticed recently
that I did something odd, and I'm surprised that xmllint hasn't
complained. The oddity is similar to what, in object oriented
programming circles, is called "overloading".
Specifically, I have two different element definitions in the same
namespace that use the same name. There's maybe a good reason for
that; one of them defines an object, assigning it an ID, while the
other points to the defined object using an IDREF.
Here's an example. First the parts of the schema, simplified:
<define name="TerminalUnitType" combine="choice">
<ref name="Phoneme"/> <!--Defined below-->
</define>
<define name="TerminalUnitType" combine="choice">
<ref name="Grapheme"/> <!--Defined below-->
</define>
... (more TerminalUnitType defns)...
<define name="Phoneme" combine="choice">
<element name="Phoneme">
...define some attrs, including id...
</element>
</define>
...
<define name="Ref2Phoneme" combine="choice">
<element name="Phoneme">
<attribute name="idref"/>
</element>
</define>
Notice that I've defined the element "Phoneme" twice: the first time
with an id (and some other stuff, not shown), and the second time with
an idref. The XML doc follows this; there are instances of Phonemes
that have the id etc.:
<Phhoneme id="phDDA" spelling="\u09A1"/>
and there are instances of Phonemes that have just the idref:
<Phhoneme idref="phDDA"/>
How did I get away with this? Is it because I used <define
name="TerminalUnitType" combine="choice">? (Looking back, I'm not
sure that defining the TerminalUnitType bought me anything.)
And is it a Bad Idea to define the name twice? Conceptually, both
indeed represent phonemes, although I'm thinking maybe I should call
the first one (the one with the 'id' attr) "PhonemeDefinition" instead
of "Phoneme".
Thoughts?
Mike Maxwell