C # Checking Xdocument Xsd with $ Symbol

I have a problem checking with C # XDocument XSD.

The following file is well-tested by Xml Spy but not .Net (C #)

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Simple.xsd">
    <Var Name="$Toto"/>
</Root>

Scheme

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="Root">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Var">
                    <xs:complexType>
                        <xs:attribute name="Name" type="ST_VariableIdentifier" use="required"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
        <xs:simpleType name="ST_VariableIdentifier">
        <xs:restriction base="xs:string">
            <xs:pattern value="$[a-z,A-Z]*"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Idea?

+5
source share
2 answers

That should work!

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Var">
          <xs:complexType>
            <xs:attribute name="Name" type="ST_VariableIdentifier" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:simpleType name="ST_VariableIdentifier">
    <xs:restriction base="xs:string">
      <xs:pattern value="[$][a-z,A-Z]*"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>
+4
source

Just add to your existing answer. This is actually a known bug in the .NET implementation of the W3C specifications (confirmed here in Connect, but will not be fixed).

MSDN provides additional information ( here ) along with the workaround mentioned above.

System.Xml World Wide Web (W3C) XML- RegEx . W3C, RegEx. , System.Xml W3C:

W3C XML- ($) . System.Xml xs: . $ [$]. , [abc $], - .

0

All Articles