[xsd-users] How to get a schema location path from existing xml
file
mark
mark at smartlink.ee
Mon Jan 4 05:43:58 EST 2010
On Mon, 4 Jan 2010 12:42:31 +0200, Boris Kolpackov
<boris at codesynthesis.com> wrote:
> Hi Mark,
>
> Mark Erlich <mark_erlich at hotmail.com> writes:
>
>> I can't get path for a schema out of the existing xml file! Is there
any
>> way to get this parameter when parsing a file?
>
> This information is not copied to the object model so the only way to
> get it is from the DOM representation. For that you will need to do
> the XML-to-DOM parsing yourself. For an example on how to do it see
> the multiroot example in the examples/cxx/tree/ directory. Once you
> get the DOM document you can do something like this:
>
> #include <xsd/cxx/xml/string.hxx> // xml::transcode
> #include <xercesc/validators/schema/SchemaSymbols.hpp>
>
> namespace xml = xsd::cxx::xml;
>
> DOMElement* root = ...
>
> const XMLCh* xsl = root->getAttributeNS (
> xercesc::SchemaSymbols::fgURI_XSI,
> xercesc::SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION);
>
> std::string sl;
>
> if (xsl != 0)
> {
> sl = xml::transcode<char> (xsl);
> }
>
> If you want to store this string as part of the object model, then
> you can customize the generated root element class to include this
> information. With this approach you can also avoid the DOM creation
> step and extract the schema directly location in the parsing
> constructor. For more information on how to do this see the wildcard
> example in the examples/cxx/tree/custom/ directory.
>
> Boris
Thank You Boris!
It helped me a lot.
Regards,
-Mark-
More information about the xsd-users
mailing list