Re: [xml] Is this legal?

David Frascone wrote:

On Wed, Jun 06, 2001 at 06:29:23PM +0100, Gary Pennington wrote:
David Frascone wrote:

Are ID/IDREF pairs supposed to be document wide, ignoring the attribute name?

If this means "does an ID have global scope in a document?", then the answer is

Given the following DTD fragment:

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT typedefn EMPTY>
<!ATTLIST typedefn
        type-name ID #REQUIRED
        description CDATA #IMPLIED

<!ELEMENT avp ((type | grouped), (enum*) )>
        name ID #REQUIRED
        description CDATA #IMPLIED
        code CDATA #REQUIRED
        may-encrypt (true | false) "true"
        mandatory-flag (disallowed | allowed | required) "allowed"
        vendor-specific (true | false) "false"
        vendor-id IDREF #IMPLIED
        constrained (true | false) "false"

Should this XML fragment be legal?  (xmllint --valid thinks so)

        <typedefn type-name"someType" />

Small typo correction ->        <typedefn type-name="someType" />

        <avp name="ARAP-Features" code="71">
                <type type-name="OctetString"/>

        <avp name="Good-AVP" code="1">
                <type type-name="someType"/>

        <avp name="Bad-AVP" code="2">
                <type type-name="ARAP-Features"/>


It looks valid to me. Your DTD fragment identifies two IDs type-name on
<typedefn> and name on <avp>. There are no clashes between these attributes that
I can see, so I think it's valid.

Even though the type-name, "ARAP-Features" is refering to an avp name

I assume you mean the type-name attribute on the <type> element...

Well, the DTD fragment you supply doesn't say anything about <type> elements.  If
<type>'s attribute type-name is an ID, then the fragment above would be invalid
(since you couldn't have two elements containing ID atrributes with the same value).

The missing piece in the puzzle above is the definition for the <type> element.

I had "assumed" that the attribute names were matched up.  Looks like I was

Each attribute name definition only applies to the element for which you declare it.
In other words, an attribute can have the same name and a completely different
meaning on different elements.

If you want to define a set of attributes that should be present on many elements and
should have the same definition, then I recommend using entities.


<!ENTITY % core    "desc CDATA 'Description'
                    ref_id ID #REQUIRED">

<!ELEMENT anelement EMPTY>

<!ATTLIST anelement     %core;

This is going off-topic for this list, so if you want to continue just mail me



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]