Giter VIP home page Giter VIP logo

Comments (5)

lcduarte avatar lcduarte commented on August 23, 2024

Hello,

First, thanks for using this library!

The library doesn't validate xml namespaces that aren't present locally, as in, present in the file system. So in order to decide if I should search locally for a namespace definition to import and validate I check if the xmlns starts with http and actively ignore those since they aren't local.

In the abc example the library searches for a xsd import tag with the namespace attribute with the value abc, and since it doesn't find it you get a parsing exception.

Hope this explanation helps.

from xsdparser.

radboudp avatar radboudp commented on August 23, 2024

Hi there,
I have a similar problem. But first: I like the library. It has a lot of potential for us. However, the XSD we like to parse has some elements inside documentation blocks which the library tries to parse, and there is no import for them. The namespace ccts is defined like this:

xmlns:ccts="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2"

So we get an "XsdSchema refers a namespace which was not imported." error when we parse our XSD. The XSD file itself is external and I could add an import for the namespace, but it seems to be elusive... What do you suggest? Any way to handle this?

<xsd:complexType name='FooType'> <xsd:annotation> <xsd:documentation xml:lang="en"> <ccts:UniqueID>123</ccts:UniqueID> <ccts:ObjectClassQualifierTerm>ENUM</ccts:ObjectClassQualifierTerm> <ccts:OfficialConstraintContextValue> <CodeListEntry><value>01</value><definition>Male</definition></CodeListEntry> <CodeListEntry><value>02</value><definition>Female</definition></CodeListEntry> </ccts:OfficialConstraintContextValue> </xsd:documentation> </xsd:annotation> <xsd:sequence> <xsd:element name='value' minOccurs='1' maxOccurs='1'> <xsd:simpleType> <xsd:restriction base='xsd:string'> <xsd:pattern value='(01|02){1}'/> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:sequence> </xsd:complexType>

from xsdparser.

aniskop avatar aniskop commented on August 23, 2024

@lcduarte, thanks for the explanation. Sounds very reasonable. I'll take my time to think a little bit about it :) That's the reason I don't close the issue. I'll do it when I'm done thinking :)
I also want to refresh my knowledge on xmlns and targetNamespace -- what they mean and what is their purpose. As far as I know, XML Schema also defines own namespace, which in turn can be used in other schemas or XML documents, so I'm in doubt a little bit about your arguments.
@radboudp , for now I see the only solution -- remove namespace without http:// before processing, which possibly is not easy. I did not try that, but I'll definitely will.

from xsdparser.

radboudp avatar radboudp commented on August 23, 2024

I solved it for now by defining an empty xsd and importing it for the namespace. Since the xml is part of the documentation, it is apparently exempt from parsing. After parsing I have seen the whole xml in the documentation field of the item. 👍

from xsdparser.

aniskop avatar aniskop commented on August 23, 2024

@lcduarte ,
I'm closing the issue, but I'm still not convinced about targetNamespace. As I understand, it defines a namespace (e.g. container) for the element names defined by the XSD. For this reason targetNamespace should not be validated. But if the name, defined by this targetNamespace is used in another XSD, then yes – validation can/must be performed, but in such case validation will be performed on xmlns.

from xsdparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.