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

Possible bug in attribute pattern matching #10

Open
pgrimsehl opened this issue Apr 30, 2018 · 0 comments
Open

Possible bug in attribute pattern matching #10

pgrimsehl opened this issue Apr 30, 2018 · 0 comments

Comments

@pgrimsehl
Copy link

Hi there,

I experience some unexpected behaviour with attribute pattern matching/validation. I'm running VS Code 1.22.2 with the XML Language Support extension v0.0.1 and JDK 1.8.0_172

Consider the following simple XML schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="sample" 
    xmlns="" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="FloatType">
        <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0.0"/>
            <xs:maxInclusive value="120.0"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Vector2Type">
        <xs:restriction base="xs:string">
            <xs:pattern value="\(\d,\d\)"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="TestElementType">
        <xs:attribute name="coord" type="Vector2Type" />
        <xs:attribute name="value" type="FloatType" />
    </xs:complexType>
    <xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="test" type="TestElementType" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

and this XML file, that is based on that schema:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:\sample.xsd">
    <test coord="(1,3)" value="120" />
</root>

Now I perform the following steps:

  1. Open sample.xml in VS Code (make sure the path to sample.xsd is correct on your system)
  2. Change attribute value to "125". This will output:
    Wert '125' ist nicht Facet-gültig in Bezug auf maxInclusive '120.0' für Typ 'FloatType' (cvc-maxInclusive-valid). 
    Wert '125' des Attributs 'value' bei Element 'test' hat keinen gültigen Typ 'FloatType' (cvc-attribute.3).
    
    as expected.
  3. Change attribute value back to "120". This will remove the error.
  4. Change attribute coord to "(1,3a)". This will output:
    Wert '(1,3a)' ist nicht Facet-gültig in Bezug auf Muster '\(\d,\d\)' für Typ 'Vector2Type' (cvc-pattern-valid).    Wert '(1,3a)' des Attributs 'coord' bei Element 'test' hat keinen gültigen Typ 'Vector2Type' (cvc-attribute.3).
    
    as expected.
  5. Change attribute coord back to "(1,3)". This will remove the error.
  6. Change attribute coord to "(1,3". This will NOT report any error.
  7. Change attribute value to "120a". This will NOT report any error.
  8. Change attribute coord to "1,3". This will output:
    Wert '1,3' ist nicht Facet-gültig in Bezug auf Muster '\(\d,\d\)' für Typ 'Vector2Type' (cvc-pattern-valid).
    Wert '1,3' des Attributs 'coord' bei Element 'test' hat keinen gültigen Typ 'Vector2Type' (cvc-attribute.3).
    '120a' ist kein gültiger Wert für 'decimal' (cvc-datatype-valid.1.2.1).
    Wert '120a' des Attributs 'value' bei Element 'test' hat keinen gültigen Typ 'FloatType' (cvc-attribute.3).
    
    as expected.
  9. Change attribute coord to "(1,3". This will NOT change the error output.
  10. Change attribute coord to "(1,3)". This will output:
    Wert '125' ist nicht Facet-gültig in Bezug auf maxInclusive '120.0' für Typ 'FloatType' (cvc-maxInclusive-valid). 
    Wert '125' des Attributs 'value' bei Element 'test' hat keinen gültigen Typ 'FloatType' (cvc-attribute.3).
    
    as expected.

There seem to be some problems to match patterns including braces. Can you confirm this?

Best regards
Peter Grimsehl

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