[xsd-users] parsing file with complete path

Schmilinsky, Remsy Remsy.Schmilinsky at ccra-adrc.gc.ca
Fri Oct 27 08:06:24 EDT 2006


It resolved my problem, thank you.

Remsy

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: October 26, 2006 2:12 PM
To: Schmilinsky, Remsy
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] parsing file with complete path


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






More information about the xsd-users mailing list