[xsd-users] Attempting to access attribute xml:base.

Jeroen N. Witmond [Bahco] jnw at xs4all.nl
Tue Nov 6 13:53:19 EST 2007


Hi Boris,

Thanks for your explanation. I have abandoned the attempts to get xsd to
generate the required code and resumed work on another implementation,
i.e. using DOM association in a customization of anyType. It now works on
version 3.1.0.a1 of xsd.

I've updated
http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/index.html to reflect
the current status.

More below:

"Boris Kolpackov" <boris at codesynthesis.com> writes:
> Hi Jeroen,
>
> Jeroen N. Witmond [Bahco] <jnw at xs4all.nl> writes:
>
>> Instead I have gotten xsd to generate all required code in
>> a custom type, without making any changes to xsd itself.
>
> This is a clever trick. I see you use sed to re-map the XML Schema
> namespace to xml_schema_2 when compiling XmlNamespace.xsd in order to
> avoid name clashes. You can achieve the same result by adding the
> following options to the command line:
>
> --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_2

Funny thing is, this works only in one case, but not in another. :)
In
http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/custom-anyType/Makefile
I have put comments on the make targets to show where it does or does not
work.

>
> Unfortunately, this whole approach has a number of deficiencies
> and won't work for the general case, as you have described in your
> other email.
>
> The problem is that anyType is quite a special type. It is a
> root of the generated type hierarchy and as such is a base
> for both simple types (i.e., type with only text content)
> and complex types (i.e., types with attributes and/or elements).
>
> Because simple types can be used as attribute and list element
> types, anyType includes parsing constructors for DOMAttr, etc.
>
> On the other hand, complex types cannot be used as attribute
> or list element types. Because of this restriction, XSD does
> not generate those constructors (DOMAttr, etc.) for complex
> types.
>
> Now if we look at your XmlNamespace.xsd:
>
>   <complexType name="wrapper_type">
>     <complexContent>
>       <extension base="anyType">
>         <attribute ref="xml:base"/>
>       </extension>
>     </complexContent>
>   </complexType>
>
> This type is a complex type because it contains the xml:base attribute.
> As a result the attribute/list constructors are not generated. But when
> you try to use it as anyType, those constructors are required.
>
> Boris
>

Jeroen.




More information about the xsd-users mailing list