[xsd-users] parsing file with complete path

Boris Kolpackov boris at codesynthesis.com
Thu Oct 26 14:11:57 EDT 2006


Hi Remsy,


Schmilinsky, Remsy <Remsy.Schmilinsky at ccra-adrc.gc.ca> writes:

> it works fine if dataFile is in the same location of the compiled
> function, however, if dataFile is a path like this ./examples/query.xml,
> the parsing fails:
>
> Debugging LibraryUtil::extractQuery, calling auto_ptr on dataFile: ./examples/query.xml
> instance document parsing failed
>
> so, it doesn't like absolute paths.


I am pretty sure this is due to the schema not being found when you use
absolute paths. In your instance document you probably have something
like this:

xsi:schemaLocation="http://www.example.com/foo foo.xsd"

When schema processor sees a declaration like this it will search for
foo.xsd in the directory relative to the document instance, in your
case this directory will be ./examples/.

There are several ways to resolve this:


(1) Disable validation by the underlying XML parser by passing the
    xml_schema::flags::dont_validate flag to one of the parsing functions,
    e.g.:

    query::queries_(dataFile.c_str(), xml_schema::flags::dont_validate)


(2) Programmatically override the schema path from XML document with an
    absolute path. This is described in the C++/Tree Mapping FAQ #2.4:

    http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/faq/#2.4

    You may also find other questions and answers in Section 2, "Validation
    and Parsing" useful.


hth,
-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/20061026/df41b3b8/attachment.pgp


More information about the xsd-users mailing list