Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W3C schema causes 'Unexpected event, expected end-tag' #56

Open
expede opened this issue Jun 22, 2016 · 5 comments
Open

W3C schema causes 'Unexpected event, expected end-tag' #56

expede opened this issue Jun 22, 2016 · 5 comments

Comments

@expede
Copy link

expede commented Jun 22, 2016

Hello,

I'm experiencing an issue when compiling XSD that includes some of the W3C schema.

iex(4)> :erlsom.compile_xsd_file <FILE PATH>
{:error,
 [exception: {:error,
   {'2 - Unexpected event, expected end-tag'}},
  stack: [:schemaType],
  received: {:startElement, 'http://www.w3.org/2001/XMLSchema', 
   'notation', 'xs',
   [{:attribute, 'system', [], [],
     'http://www.w3.org/2000/08/XMLSchema.xsd'},
    {:attribute, 'public', [], [], 'structures'},
    {:attribute, 'name', [], [], 'XMLSchemaStructures'}]}]}

These appear to be the lines that break compilation:

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
<xs:import namespace="http://www.w3.org/1999/XSL/Transform" schemaLocation="http://www.w3.org/2007/schema-for-xslt20.xsd"/>

I also get the same error when I download and attempt compilation on those schemas directly.

This may be related to #45 and this exchange from 2009. If that is the case, has a workaround found?

Thanks! 😄

@willemdj
Copy link
Owner

Hi,

Yes, it is related to the problem from 2009. The schema for xslt imports the schema for XML-schema (XMLSchema.xsd). That schema uses the 'notation' feature, which is not supported.

What you can easily do is remove some of these imports. They are probably only referred to via "xs:any" types. This means that you will still be able to parse the XML documents, but there will be no value for these "any" elements. That means that you are fine if you are not interested in these values, or of they do not occur.

If you do really need these values, then you could try what I did for SOAP: remove the reference to XML Schema (so use an edited version of the xslt schema), compile it and then add a simplified version of XMLSchema.xsd to the result using the (undocumented) function erlsom:add_xsd_model() - see here for an example.

In any case you have to be aware that the result of parsing an XML that has such a complex schema will be a pretty complicated data structure, so getting the information that you need from that will probably not be easy.

Good luck,
Willem

@expede
Copy link
Author

expede commented Jun 27, 2016

Thanks for the quick response, @willemdj 😄

Thanks for the suggestions. I tried removing the imports, but it looks like the schema is relying on more than the xs:any tags. I need to be able to display, modify, and validate the modified XML doc, so I can't skip fields, and the schema is part of an external standard 😭

Does erlsom:add_xsd_model allow me to merge an arbitrary tree into a schema?

getting the information that you need from that will probably not be easy.

Couldn't agree more, but it's unavoidable 😢

Thanks again!

@willemdj
Copy link
Owner

erlsom:add_xsd_model allows you include the schema for XML schema. So you could try to remove the import of that schema from the relevant XSDs (such as the one for XLST), then compile that and finally apply erlsom:add_xsd_model to the result.

If you can let me know exactly which XSD/standard you are trying to use, I can take a closer look and maybe make some more specific suggestions.

@expede
Copy link
Author

expede commented Jun 28, 2016

I just took another look, and I think that I wasn't going far enough down the chain of import dependencies. I'm going to give your earlier suggestion another whirl, but I'm having encouraging results so far 😄 Thanks!

@expede
Copy link
Author

expede commented Jun 29, 2016

Everything appears good with add_xsd_model 👍 Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants