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

Boris Kolpackov boris at codesynthesis.com
Tue Jan 16 16:37:00 EST 2007


Hi Jeroen,

Sorry it took me so long to reply to your post.

Jeroen N. Witmond <jnw at xs4all.nl> writes:

> Just documenting the obvious: In this case, file xml.cxx can be
> ignored, it does not need to be compiled, and file xml.o is not needed
> by the linker.  One step beyond is not to use file xml.xsd at all, and
> to create a dummy file xml.hxx.

Thanks for mentioning this. I am sure someone will find this information
useful.


> Question: Shouldn't the Tree Mapping User Manual[4], in the paragraph
> starting with "Keeping association with DOM nodes is useful for
> dealing", explicitely mention that the use of the
> xml_schema::flags::keep_dom flag requires the use of the flag
> xml_schema::flags::dont_initialize as well?

XSD is being smart here: it check that you've passed keep_dom and
does not initialize the runtime. In other words keep_dom implies
dont_initialize.


> Question: I thought I had to release whatever is returned from
> DOMAttr::getValue(),

Pretty much everything returned by DOM API belongs to the DOM
document you are working with and is released when the document
is released. So you do not need to free the string returned from
DOMAttr::getValue(). See the Xerces-C++ Programming Guide for
more information:

http://xml.apache.org/xerces-c/program.html


> Unfortunately, but IMHO unavoidably, 'custom-types' still requires the
> xml_schema::flags mentioned above.  Without them, the DOM is not
> available during the execution of the bodies of the contructors of the
> custom types.

Not in all constructors, but in the one that has const DOMElement& as its
argument. The idea is to check for xml:base in that c-tor and store the
value in some data member.


> > 3. This is a variation of (2), for cases where you have a lot of unrelated
> >    types that all allow for <xs:anyAttribute namespace="##other"/>. In this
> >    case you may want to customize the xml_schema::type class which
> >    corresponds to XML Schema anyType and is a base for every generated
> >    types. You can customize xml_schema::type by inheriting from the
> >    original and checking for xml::base in the constructor. Again, see the
> >    C++/Tree Mapping Customization Guide[2] and examples for details.
> >
> > [1] http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.2
> >
> > [2] http://wiki.codesynthesis.com/Tree/Customization_guide
>
> I'm not sure I understand what you are saying here, but it sounds like
> making modifications to xsd's source.

No, you do not need to modify XSD source code, everything can be
accomplished by customization. There is an XML Schema anyType which
is mapped to xml_schema::type C++ class. This class is a root of the
hierarchy: every generated type inherits from this class (directly
or indirectly). One of its constructors is in the form:

type (const DOMElement& e, /*other stuff*/);

It is called every type an DOM element is parsed into a C++ class
(because every generated class always call its base c-tor) The idea
is to customize this type with the logic for handling of xml:base,
etc. Since this type is a base for all the generated types then
all generated types will automatically have this functionality.
Hope this makes sense.


> This is sufficient for my immediate needs, but I would like to see
> options added to xsd to generate and use code for a full
> implementation of the xml namespace, along the line you suggested, or
> along the line I implemented it.

I would much prefer to have this implemented using the customization
technique outlined above rather than adding options and code to XSD
to support this popular but still special case. If you could come up
with the customization of xml_schema::type that implements this then
we can definitely publish it in some form or another (e.g., in the
wiki).


> [3] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/index.html

That's an impressive document you have here. Are you going to keep
it permanently? If so then I would like to add a link to it from the
wiki. Also, the link in the caption of the page points to
codesynthesis.org, I think it should be codesynthesis.com.


thanks,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070116/41f30e6d/attachment.pgp


More information about the xsd-users mailing list