redhat-developer / redhat-developer/vscode-xml

xs:keyref not working

Open
#1,094 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Take an XSD like this one here:

<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
  <xs:complexType name='source'>
    <xs:attribute name='name' type='xs:string' use='required'/>
  </xs:complexType>

  <xs:complexType name='target'>
    <xs:choice minOccurs='0' maxOccurs='unbounded'>
      <xs:element name='reference' type='xs:string'/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name='root'>
    <xs:choice minOccurs='0' maxOccurs='unbounded'>
      <xs:element name='source' type='source'/>
      <xs:element name='target' type='target'/>
    </xs:choice>
  </xs:complexType>

  <xs:element name='root' type='root'>
    <xs:unique name='unique.source.name'>
      <xs:selector xpath='source'/>
      <xs:field xpath='@name'/>
    </xs:unique>
    <xs:keyref name='keyref.target.reference' refer='unique.source.name'>
      <xs:selector xpath='target'/>
      <xs:field xpath='reference'/>
    </xs:keyref>
  </xs:element>
</xs:schema>

with an XML like this:

<root>
  <source name='test1'/>
  <source name='test1'/>
  <target>
    <reference>test2</reference>
  </target>
</root>

The extension will recognize that "test1" is duplicate (xs:unique works) but it will neither recognize that "test2" does not refer to a known name nor does it propose names on completion inside the "reference" tag at all.

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

Reproduce the issue with the supplied XSD and XML, then trace how the extension handles xs:unique, xs:keyref validation, and completion inside reference elements. Done means the invalid test2 reference is reported and completion proposes the relevant source names.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.