[xsde-users] ignoring parts of the schema - and referenced schemas

Eric Broadbent eric.broadbent at csr.com
Wed Nov 30 15:39:43 EST 2011

Just an update - I tried the method of creating the parser skeleton/implementation code for this "extension" schema and building it into the application, in hopes that parser would recognize the attribute if an element's attributes were extended like this.
However I still get "unexpected attribute encountered".
So I'm going to try turning off validation next.

On Nov 29, 2011, at 11:02 PM, Eric Broadbent wrote:

> Hi Boris,
> thanks for the reply - sorry my previous query was vague.
> I found an example of this kind of namespace reference in Office documents.
> Here is the root document element from a random Word docx file on my computer:
> <w:document xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
> xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
> xmlns:mv="urn:schemas-microsoft-com:mac:vml"
> xmlns:o="urn:schemas-microsoft-com:office:office"
> xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
> xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
> xmlns:v="urn:schemas-microsoft-com:vml"
> xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
> xmlns:w10="urn:schemas-microsoft-com:office:word"
> xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
> xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
> ve:Ignorable="mv"
> ve:PreserveAttributes="mv:*">
> According to specs I am able to see, the "document" element does not have any attributes.
> 	http://www.schemacentral.com/sc/ooxml/e-w_document.html
> The document tag contains references to other schemas necessary to specify child elements, and then there are two attributes in the "ve" namespace:
> 	ve:Ignorable
> 	ve:PreserveAttributes
> In order to be able to parse these attributes, the parser must know about the "markup-compatibility" schema, however the child elements do not use this schema - it's only necessary to interpret these extra attributes.
> So unless one processes the "markup-compatibility" schema with XSD and generates parsers for it - these attributes will be "unexpected" and declared invalid.
> Is this the only way around these kind of "extension" attributes?
> Thanks for your help,
> -Eric
> On Nov 29, 2011, at 10:17 AM, Boris Kolpackov wrote:
>> Hi Eric,
>> Eric Broadbent <Eric.Broadbent at csr.com> writes:
>>> The problem seems to be that I have not generated parsing code for all the 
>>> possible schemas that can be referenced via attributes.
>>> It seems that there can be "optional" elements, which essentially allow 
>>> namespaces to be extended.
>>> This looks something like this - appearing in any given element attribute 
>>> list:
>>>            xmlns:foo="http://schemas.foo.org/2011/XMLSchema-foo"
>>>            xmlns:bar="http://schemas.foo.org/2011/XMLSchema-bar"
>>>            foo:foobar=bar
>>> where "foobar" is an attribute in the schema XMLSchema-foo, and "bar" is yet
>>> another namespace represented by another schema.  The use of the "foobar"
>>> attribute to give meaning to the "bar" namespace is dependent on the ability
>>> to interpret the semantics of the "foo" schema.
>>> As far as my application is concerned, I do not need to do anything with
>>> these attributes or namespaces, and I would like the parser to ignore them.
>>> However, since this kind of namespace reference is dynamic, perhaps there is
>>> no opportunity to tell the parser to skip over these attributes - in the
>>> same way that we can tell it to skip over elements.  Therefore I am not sure
>>> how to deal with this situation - except to have pre-processed any possible
>>> "optional" schema beforehand and built parsers for it.
>>> My question is - is there any way to skip over unknown element attributes 
>>> like this that are referring to other schemas that I have no handlers for
>>> (and no need for)?
>> I am having a hard time understanding how the "extension schemas" are
>> working in your setup without seeing some concrete examples. Generally,
>> though, you can skip any valid element or attribute by simply not
>> providing a parser for it. By valid I mean that it is valid for such
>> an element/attribute to appear in the content, per the schema.
>> Normally, schema extensions are arranged using the xsd:any or
>> xsd:anyAttribute wildcards. By default their content will be ignored
>> but the namespaces of the elements/attributes will still be checked.
>> The only way to ignore an invalid element or attribute (i.e., one
>> that is not allowed by the schema) is to disable validation.
>> Boris
>> To report this email as spam click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== .
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
> More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog

More information about the xsde-users mailing list