Hash: SHA1
Hello,
I've some namespace problems when defining default values for attributes.
My problem seems to come from the fact that the attributes are defined in a
different namespace from the element.
I've defined the XLink attributes in xlink.xsd. (I've copied just a subset)
I've written a personal schema defining elements in an other namespace in
schema.xsd. I defined default values for some XLink attributes.
But, when I process doc.xml,
the element
<link xl:href="http://www.google.fr"> Google</link>
becomes
<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>
But I expected:
<link xl:href="http://www.google.fr" xl:show="new" xl:actuate="onR equest"
xl:type="simple ">Google</link>
I don't understand why the XML processor (Xerces in my case) deletes the xl
namespace prefix.
Note, that the processed file is not valid any more !!!
As a consequence, Mozilla doesn't interpret this link node as an hypertext
node. :-(
How can I do in order to define default values for attributes that are
defined in a different namespace from the elements ??
Thanks for any help !
Lénaïc.
doc.xml <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
<root xmlns="http://MySchema"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://MySchema schema.xsd">
<link xl:href="http://www.google.fr"> Google</link>
<link xl:href="http://www.w3.org">W3C </link>
<link xl:type="simple " xl:href="http://www.xmlfr.org" xl:show="new"
xl:actuate="onR equest">XML</link>
</root>
end of doc.xml <<< processed doc.xml <<<
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
<root xmlns="http://MySchema" xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://MySchema schema.xsd">
<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>
<link xl:href="http://www.w3.org" show="new" actuate="onRequ est"
type="simple">W 3C</link>
<link xl:type="simple " xl:href="http://www.xmlfr.org" xl:show="new"
xl:actuate="onR equest">XML</link>
</root>
end of processed doc.xml <<< xlink.xsd <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd">
<xs:schema xmlns="http://www.w3.org/1999/xlink"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace ="http://www.w3.org/1999/xlink"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d">
<xs:attribute name="type">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="simple" />
<xs:enumerati on value="extended " />
<xs:enumerati on value="locator" />
<xs:enumerati on value="arc" />
<xs:enumerati on value="resource " />
<xs:enumerati on value="title" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="href" type="xs:anyURI " />
<xs:attribute name="show">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="new" />
<xs:enumerati on value="replace" />
<xs:enumerati on value="embed" />
<xs:enumerati on value="other" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="actuate">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="onLoad" />
<xs:enumerati on value="onReques t" />
<xs:enumerati on value="other" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="label" type="xs:NCName " />
<xs:attribute name="from" type="xs:NCName " />
<xs:attribute name="to" type="xs:NCName " />
<xs:attributeGr oup name="simpleLin k">
<xs:attribute ref="xl:type" fixed="simple" />
<xs:attribute ref="xl:href" use="optional" />
<xs:attribute ref="xl:show" use="optional" />
<xs:attribute ref="xl:actuate " use="optional" />
</xs:attributeGro up>
</xs:schema>
end of xlink.xsd <<< schema.xsd <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd">
<xs:schema xmlns="http://MySchema"
xmlns:my="http://MySchema"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace ="http://MySchema"
elementFormDefa ult="qualified"
attributeFormDe fault="unqualif ied">
<xs:import namespace="http ://www.w3.org/1999/xlink"
schemaLocation= "xlink.xsd" />
<xs:element name="root" type="my:rootTy pe" />
<xs:complexTy pe name="rootType" >
<xs:sequence>
<xs:element name="link" type="my:linkDe faultType"
maxOccurs="unbo unded" />
</xs:sequence>
</xs:complexType>
<xs:complexTy pe name="linkBaseT ype">
<xs:simpleConte nt>
<xs:extension base="xs:string ">
<xs:attributeGr oup ref="xl:simpleL ink" />
</xs:extension>
</xs:simpleConten t>
</xs:complexType>
<xs:complexTy pe name="linkDefau ltType">
<xs:simpleConte nt>
<xs:restricti on base="my:linkBa seType">
<xs:attribute ref="xl:show" default="new" />
<xs:attribute ref="xl:actuate " default="onRequ est" />
</xs:restriction>
</xs:simpleConten t>
</xs:complexType>
</xs:schema>
end of schema.xsd <<<
- --
(o_ Lénaïc HUARD
//\ Le**********@la poste.net
V_/_ KeyID: 0x04D2E818
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBMMPBjYE jJATS6BgRAuA2AJ 4t+lz0R8CeGN9XZ XWUdh+qlWHpSwCg n4F7
TzhlOG7NXMguHDy Dm753Tns=
=EfcB
-----END PGP SIGNATURE-----