Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XML DTD Validation, namespaces and best practices

From: richard@------.--.--.-- (------- -----)
To: NULL
Date: 11/2/2005 11:03:00 PM
In article <1130958516.704039.273980@g...>,
johnmack@g... <johnmack@g...> wrote:

>In my instance, to declare the namespace, I have this on my root
>element:
>     <root xmlns:xlink="http://www.w3.org/1999/xlink">
>     ...
>     <mylink xlink:href="http://foo.com">
>     ....
>
>Declaring things as I've done on the <root> element here, is this
>proper?

Yes.  You don't have to declare them on the root, but it's often
convenient.

>Do I have to declare 'xmlns:xlink' as an attribute on <root>
>in my DTD?

Yes.

>Or do attributes starting with 'xmlns:' trigger an innate
>XML processing command and therefore do not need to be defined in a
>DTD?

No, DTDs have not been updated to take account of namespaces, so
namespace declaration attributes have to be declared like any others.

>In my DTD I have explicitly defined "xlink:href" as attribute like so:
><!ELEMENT mylink        (#PCDATA)>
><!ATTLIST mylink
>     xlink:href CDATA #REQUIRED>
>
>Is this an acceptable approach or is the following a better way to do
>it in the DTD?:
><!ATTLIST mylink
>     xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">

The second saves you having to remember to put it on the element in
the instance, but if it's declared in the external subset you'd better
be sure that all the XML processors you use read the external subset.

>I'm using the XML validator at:
>"http://www.stg.brown.edu/service/xmlvalid/", and when I have 'Relax
>namespace checks' selected, my XML documents validate. To clarify
>further they only validate when I have the namespace in <root> ( as
>noted above) *and* declaring explicitly 'xlink:href' as an attribute
>(<!ATTLIST mylink xlink:href CDATA #REQUIRED>) on 'mylink' in my DTD.
>Since the validator says this is OK, I'm using what I've done is OK?
>It seems weird to have to explicitly declare 'xlink:href' as an
>attribute in my DTD so I'm thinking this may not be proper.  Are there
>other options for me to pursue?  Is there a suggested best practice?

The "relaxed namespace checks" are supported by any standard.  Your
document is not DTD-valid unless you declare the attribute.  On the
other hand, you don't *have* to make your documents DTD-valid at all.
If you find that the "relaxed" validation is useful, and you don't
need true DTD-validity, then it's a reasonable approach.

-- Richard


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent