J
johnmack
In my XML instances I want to use the XLink namespace for attributes on
certain elements. I'm having quite a hard time determining how to
reflect this properly in my DTD and XML instances.
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? Do I have to declare 'xmlns:xlink' as an attribute on <root>
in my DTD? Or do attributes starting with 'xmlns:' trigger an innate
XML processing command and therefore do not need to be defined in a
DTD?
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">
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?
It's been tough to find clear solutions for this matter.
Thanks for any insight,
John Mack
certain elements. I'm having quite a hard time determining how to
reflect this properly in my DTD and XML instances.
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? Do I have to declare 'xmlns:xlink' as an attribute on <root>
in my DTD? Or do attributes starting with 'xmlns:' trigger an innate
XML processing command and therefore do not need to be defined in a
DTD?
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">
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?
It's been tough to find clear solutions for this matter.
Thanks for any insight,
John Mack