RE: Help validating XML against an XSD?

2010-03-15 Thread Scott Cantor
>> I seem to recall finding no reliable way to prevent it from following
>> imports in dependent schemas in the past without registering my own
>> resolver and playing some games, so my strategy has been to register
>> the namespace -> entity mappings in various ways, rather than
>> registering and loading schemas directly like your sample does.
>
> fgXercesLoadSchema won't prevent loading imported/included schemas that
> are referenced from schemas that you explicitly load with the
> loadGrammar() calls. Only schemas that are specified in the XML
> documents.

At least with imports, I suppose that in the absence of circular references,
one could strip the import statements of their paths and preload in the
order needed to resolve the imports, but that won't help with includes. Oh
well.

Thanks for the clarification,
-- Scott



-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



Re: Help validating XML against an XSD?

2010-03-15 Thread Boris Kolpackov
Hi Scott,

Scott Cantor  writes:

> I think I know the answer, but is the fgXercesLoadSchema feature new in 3.x?

Yes, it is available since 3.0.0.


> I seem to recall finding no reliable way to prevent it from following
> imports in dependent schemas in the past without registering my own 
> resolver and playing some games, so my strategy has been to register 
> the namespace -> entity mappings in various ways, rather than 
> registering and loading schemas directly like your sample does.

fgXercesLoadSchema won't prevent loading imported/included schemas
that are referenced from schemas that you explicitly load with the
loadGrammar() calls. Only schemas that are specified in the XML
documents.

Boris

-- 
Boris Kolpackov, Code Synthesishttp://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



Re: Help validating XML against an XSD?

2010-03-15 Thread Boris Kolpackov
Hi,

Scott Cantor  writes:

> > Another simple way to achieve the same is setting the
> > fgXercesSchemaExternalSchemaLocation and
> > fgXercesSchemaExternalNoNameSpaceSchemaLocation parameters (or using
> > setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation
> > methods if available).
> 
> [...]
> 
> But it's also important to note that naively using those options won't work
> either, because (in what I've always considered a buggy "feature", though
> it's probably to spec) those overrides only apply to the schema lookup
> *within* the XML instance being validated, and NOT to any lookup of imported
> schemas in the schemas you pull in. They only go one layer deep, in other
> words.

The other problem with this approach is that the resolution of the
paths is relative to the document path unless they are absolute
URI qualified with 'file://' or similar.


> So a complete solution (in code) really has to register an EntityResolver
> and fully hijack the whole mechanism in some brittle ways, unfortunately.

If you are using a fairly-recent version of Xerces-C++ (i.e., 3.0.0 or
later) then a much simpler and more robust solution is as described
in the blog mentioned above.

Boris

-- 
Boris Kolpackov, Code Synthesishttp://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



RE: Help validating XML against an XSD?

2010-03-15 Thread Scott Cantor
> Seeing that this is becoming sort of a FAQ (though without a good answer),
> I have written a little post plus included a couple of examples that you
> may find useful:
> 
> http://www.codesynthesis.com/~boris/blog/2010/03/15/validating-external-
> schemas-xerces-cxx/

I think I know the answer, but is the fgXercesLoadSchema feature new in 3.x?

I seem to recall finding no reliable way to prevent it from following
imports in dependent schemas in the past without registering my own resolver
and playing some games, so my strategy has been to register the namespace ->
entity mappings in various ways, rather than registering and loading schemas
directly like your sample does. I suspect that still has to be done if
compatibility with 2.x is required.

-- Scott



-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



RE: Help validating XML against an XSD?

2010-03-15 Thread Scott Cantor
> Another simple way to achieve the same is setting the
> fgXercesSchemaExternalSchemaLocation and
> fgXercesSchemaExternalNoNameSpaceSchemaLocation parameters (or using
> setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation
> methods if available).

If you're writing code, yes, in contrast to just trying to use the utilities
as written, because they don't expose options for those settings (not that
they couldn't).

But it's also important to note that naively using those options won't work
either, because (in what I've always considered a buggy "feature", though
it's probably to spec) those overrides only apply to the schema lookup
*within* the XML instance being validated, and NOT to any lookup of imported
schemas in the schemas you pull in. They only go one layer deep, in other
words.

So a complete solution (in code) really has to register an EntityResolver
and fully hijack the whole mechanism in some brittle ways, unfortunately.

-- Scott



-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



Re: Help validating XML against an XSD?

2010-03-15 Thread Vitaly Prapirny

Boris Kolpackov wrote:

Hi Timothy,

Stone, Timothy M  writes:


Hm, I've given it some offort, but cannot seem to get it going.  I have a
.xsd and a .xml file, and I just want to test if the XML is compliant with
the XSD.


Seeing that this is becoming sort of a FAQ (though without a good answer),
I have written a little post plus included a couple of examples that you
may find useful:

http://www.codesynthesis.com/~boris/blog/2010/03/15/validating-external-schemas-xerces-cxx/

Boris



Another simple way to achieve the same is setting the 
fgXercesSchemaExternalSchemaLocation and 
fgXercesSchemaExternalNoNameSpaceSchemaLocation parameters (or using 
setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation 
methods if available).


Good luck!
Vitaly

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



Re: Help validating XML against an XSD?

2010-03-15 Thread Boris Kolpackov
Hi Timothy,

Stone, Timothy M  writes:

> Hm, I've given it some offort, but cannot seem to get it going.  I have a
> .xsd and a .xml file, and I just want to test if the XML is compliant with
> the XSD.

Seeing that this is becoming sort of a FAQ (though without a good answer),
I have written a little post plus included a couple of examples that you
may find useful:

http://www.codesynthesis.com/~boris/blog/2010/03/15/validating-external-schemas-xerces-cxx/

Boris

-- 
Boris Kolpackov, Code Synthesishttp://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org