redhat-developer / redhat-developer/vscode-xml

Possible Bug with more than one SchemaLocation

Open
#959 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug xsd
Dominant language
TypeScript
Stars
328
Forks
101
Avg merge
1d 17h
Merged PRs (30d)
7

Description

Hi, with my students i try to separate definition of types in our namespace ( AlumneTipus) from the general definition of alumno.

Im following this: http://www.java2s.com/Tutorial/XML/0060__XML-Schema/Onexmldocumentwithtwoxmlschemas.htm

But it gives me error:

XmlFile:

<alumnat xmlns="http://www.example.org/Alumne" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.example.org/AlumneTipus alumnetipus.xsd 
                        http://www.example.org/Alumne alumneschema.xsd">
    <alumno>
        <nombre>aaaaa</nombre>
        <apellidos>Delos Palotes</apellidos>
        <direccion>Cuatro esquinas</direccion>
        <codigopostal>30190</codigopostal>
    </alumno>
</alumnat>`

XSD "General" File:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/Alumne"
    xmlns="http://www.example.org/Alumne" 
    xmlns:MeusTipus="http://www.example.org/AlumneTipus" 
    elementFormDefault="qualified">
    
    <xs:element name='alumnat'>
        <xs:complexType>
            <xs:sequence>
                <xs:element name='alumno' minOccurs='0' maxOccurs='unbounded'>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name='nombre' minOccurs='1' maxOccurs='1' type="MeusTipus:tnomstring" />
                            <xs:element name='apellidos' minOccurs='1' maxOccurs='1'
                                type="xs:string" />
                            <xs:element name='direccion' minOccurs='1' maxOccurs='1'
                                type="xs:string" />
                            <xs:element name='codigopostal' minOccurs='1' maxOccurs='1'
                                type="xs:string" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>`

XSD "With definition of tipus" File:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.example.org/AlumneTipus" 
    targetNamespace="http://www.example.org/AlumneTipus"
    elementFormDefault="qualified">
    
    <xs:simpleType name="tnomstring">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z]{5}"/>
        </xs:restriction>
   </xs:simpleType>

 
</xs:schema>`

So vscode give me these errors:

image

[{
	"resource": "/home/eduardo/Descargas/alumne.xml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "There are '2' errors in 'alumneschema.xsd'.",
	"source": "xml",
	"startLineNumber": 12,
	"startColumn": 55,
	"endLineNumber": 12,
	"endColumn": 71,
	"relatedInformation": [
		{
			"startLineNumber": 21,
			"startColumn": 88,
			"endLineNumber": 21,
			"endColumn": 110,
			"message": "src-resolve.4.2: Error resolving component 'MeusTipus:tnomstring'. It was detected that 'MeusTipus:tnomstring' is in namespace 'http://www.example.org/AlumneTipus', but components from this namespace are not referenceable from schema document 'file:///home/eduardo/Descargas/alumneschema.xsd'. If this is the incorrect namespace, perhaps the prefix of 'MeusTipus:tnomstring' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///home/eduardo/Descargas/alumneschema.xsd'.",
			"resource": "/home/eduardo/Descargas/alumneschema.xsd"
		},
		{
			"startLineNumber": 21,
			"startColumn": 88,
			"endLineNumber": 21,
			"endColumn": 110,
			"message": "src-resolve: Cannot resolve the name 'MeusTipus:tnomstring' to a(n) 'type definition' component.",
			"resource": "/home/eduardo/Descargas/alumneschema.xsd"
		}
	]
}]

[{
	"resource": "/home/eduardo/Descargas/alumneschema.xsd",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "src-resolve.4.2",
	"severity": 8,
	"message": "src-resolve.4.2: Error resolving component 'MeusTipus:tnomstring'. It was detected that 'MeusTipus:tnomstring' is in namespace 'http://www.example.org/AlumneTipus', but components from this namespace are not referenceable from schema document 'file:///home/eduardo/Descargas/alumneschema.xsd'. If this is the incorrect namespace, perhaps the prefix of 'MeusTipus:tnomstring' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///home/eduardo/Descargas/alumneschema.xsd'.",
	"source": "xsd",
	"startLineNumber": 21,
	"startColumn": 88,
	"endLineNumber": 21,
	"endColumn": 110
},{
	"resource": "/home/eduardo/Descargas/alumneschema.xsd",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "src-resolve",
	"severity": 8,
	"message": "src-resolve: Cannot resolve the name 'MeusTipus:tnomstring' to a(n) 'type definition' component.",
	"source": "xsd",
	"startLineNumber": 21,
	"startColumn": 88,
	"endLineNumber": 21,
	"endColumn": 110
}]

I attach the files, any help would be apreciated.
As said id like to create a namespace http://www.example.org/AlumneTipus in file alumnetipus.xsd with the definition of the different types that we are going to configure.
In alumneschema.xsd in namespace http://www.example.org/Alumne the general definition of the schema.

alumne.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the diagnostics in VS Code with the attached XML, alumneschema.xsd, and alumnetipus.xsd files. Inspect how the XML extension resolves the cross-namespace schema reference, and determine whether the reported error is caused by the extension or by the schema setup. Done means the expected validation behavior is documented or the reproducible extension defect is fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode, xml
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.