<xs:attribute> with ref attribute nested in <xs:attribteGroup> does't work problem

A

Aray

Let us see the test file following:

-------file nowork.xsd begin-----------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.bonc.com.cn" targetNamespace="http://www.bonc.com.cn"
elementFormDefault="qualified">
<xs:attribute name="testAttribute" type="xs:string"/>
<xs:attributeGroup name="testAttributeGroup">
<xs:attribute ref="testAttribute"/>
</xs:attributeGroup>
<xs:complexType name="testType">
<xs:attributeGroup ref="testAttributeGroup"/>
</xs:complexType>
<xs:element name="test" type="testType"/>
</xs:schema>
-------file nowork.xsd end-----------


-------file nowork.xml end-----------
<?xml version="1.0" encoding="UTF-8"?>
<test
xmlns="http://www.bonc.com.cn"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bonc.com.cn nowork.xsd"

testAttribute="a"
-------file nowork.xml end-----------

I validate the nowork.xml with xmlSpy 2007. the following error countered:

------------error message begin----------------
File F:\work\temp\xmlStudy\form\nowork.xml is not valid.
Attribute 'testAttribute' is not allowed in element <test>
Error location: test / @testAttribute
Details
cvc-complex-type.3.2.1: Complex type definition 'testType' of element
<test> does not allow attribute 'testAttribute' and no attribute wildcard
matches it.
cvc-elt.5.2.1: The element <test> is not valid with respect to the actual
type definition 'testType'.
------------error message end----------------

What I expect is, The nowork.xml is a valid xml file. But it doesn't.

I am newbie to xml and schema. I have just fished to read the XML Schema
Tutorial on http://www.w3schools.com/schema/default.asp. Did I miss
something?

Any help will be preciouse

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top