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

Validation / intellisense using XSDs with same namespace #1030

Open
dkus opened this issue Oct 17, 2024 · 0 comments
Open

Validation / intellisense using XSDs with same namespace #1030

dkus opened this issue Oct 17, 2024 · 0 comments

Comments

@dkus
Copy link

dkus commented Oct 17, 2024

Hi,

I have two XSDs with same namespace:

document.a.1.0.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.0" xmlns="urn:xsd:document.a.1.0" targetNamespace="urn:xsd:document.a.1.0">
  <xs:element name="Document" type="DocumentType"></xs:element>
  <xs:complexType name="DocumentType">
    <xs:sequence>
      <xs:element name="A1" type="xs:string" fixed="1"></xs:element>
      <xs:element name="A2" type="A2Type"></xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="A2Type">
    <xs:sequence>
      <xs:element name="A3" type="xs:string" fixed="3"></xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

document.a.1.0.add.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.0" xmlns="urn:xsd:document.a.1.0" targetNamespace="urn:xsd:document.a.1.0">
  <xs:element name="Document" type="DocumentType"></xs:element>
  <xs:complexType name="DocumentType">
    <xs:sequence>
      <xs:element name="A1" type="xs:string" fixed="2"></xs:element>
      <xs:element name="A2" type="A2Type_2"></xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="A2Type_2">
    <xs:sequence>
      <xs:element name="A3" type="xs:string" fixed="33"></xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

And I generally use validation using catalog. For this XSD's I have the following entries in catalog.

catalog.xml

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
  <system systemId="document.a.1.0.xsd" uri="document.a.1.0.xsd" />
  <system systemId="document.a.1.0.add.xsd" uri="document.a.1.0.add.xsd" />
  <uri name="urn:xsd:document.a.1.0" uri="document.a.1.0.xsd" />
  <uri name="urn:xsd:document.a.1.0" uri="document.a.1.0.add.xsd" />
</catalog>

The validation of the following XML passes in VsCode using this extension (I would say due to order of XSDs in catalog):

<?xml version="1.0" encoding="UTF-8"?>
<p:Document xmlns:p="urn:xsd:document.a.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <p:A1>1</p:A1>
  <p:A2>
    <p:A3>3</p:A3>
  </p:A2>
</p:Document>

But, this one fails:

<?xml version="1.0" encoding="UTF-8"?>
<p:Document xmlns:p="urn:xsd:document.a.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <p:A1>2</p:A1>
  <p:A2>
    <p:A3>33</p:A3>
  </p:A2>
</p:Document>

When I do validation in Java code I must choose the correct XSD to validate XML.
The issue may be related to XERCESJ-1130.

Is there a way to do the similar in VsCode, keeping the catalog as-is, but choose correct XSD?

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

1 participant