xml reference problem

G

gg

is it possible to have a complex type with attribute pointing to another
member
of the complex type?

for example, I tried


<xsd:complexType name="RegexTypes" />
<xsd:sequence>
<xsd:element name="regexName" type="xsd:Name" />
<xsd:element ref="comment" />
</xsd:sequence>
<xsd:attribute name="level" type="xsd:string" />
...
<xsd:attributeGroup ref="RegexTypes">

<!-- error on next line's xsd:attribute, same for replacing with
element -->
<xsd:attribute name="nextRegexLink" type="regexName" minOccurs="0"
maxOccurs="unbounded" />
</xsd:attributeGroup>
</xsd:complexType>


</xsd:complexType>
<xsd:element name="comment" type="xsd:string">
</xsd:element>


and I get:
Warning 2 The element 'attributeGroup' in namespace
'http://www.w3.org/2001/XMLSchema' has invalid child element 'attribute' in
namespace 'http://www.w3.org/2001/XMLSchema'. List of possible elements
expected: 'annotation' in namespace 'http://www.w3.org/2001/XMLSchema'.
D:\data\Ieproj\Util\RegexDotNet\regex.xsd 34 8 Miscellaneous Files

Warning 1 The 'http://www.w3.org/2001/XMLSchema:attribute' element is not
supported in this context. D:\data\Ieproj\Util\RegexDotNet\regex.xsd 34 8
Miscellaneous Files




I tried another approach that seem to be acceptable to ms visual studio but
not to NetBean IDE 5.5:
<xsd:group name="RegexCollection">
<xsd:sequence>
<xsd:element name="favorite" type="xsd:string" />
..............

<xsd:element ref="comment" />
<xsd:element name="regexType" type="RegexTypes" />
<xsd:element name="nextRegexLink" type="regexName" minOccurs="0"
maxOccurs="unbounded" />

</xsd:sequence>
</xsd:group>
<xsd:complexType name="RegexTypes">
<xsd:sequence>
<xsd:element name="regexName" type="xsd:Name" />
<xsd:element ref="comment" />
</xsd:sequence>
.............


</xsd:complexType>

src-resolve: Cannot resolve the name 'regexName' to a(n) 'type definition'
component. [47]
XML validation finished.
 
G

gg

apparently not according to w3 attribute group spec.


however
something like the following does get validated by Netbean 5.5
Netbean does accept something like this
<xsd:group name="RegexCollection">
<xsd:sequence>
...
<xsd:element ref="comment" />
<xsd:element name="regexType" type="RegexTypes" />
<xsd:element name="nextRegexLink" type="regexNameType" />
</xsd:sequence>
</xsd:group>


<xsd:complexType name="regexNameType">
<xsd:sequence>
<xsd:unique name="item-name-uniqueness">
<xsd:selector xpath="item" />
<xsd:field xpath="name" />
</xsd:unique>
<xsd:element name="regexNameBase" type="xsd:Name" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="RegexTypes">
<xsd:sequence>
<xsd:element name="regexName" type="regexNameType" />
...
</xsd:sequence>
</xsd:complexType>


I tried to effect the same orginal end result by specifying uniqueness on
the complexType regexNameType


gg said:
is it possible to have a complex type with attribute pointing to another
member
of the complex type?

for example, I tried


<xsd:complexType name="RegexTypes" />
<xsd:sequence>
<xsd:element name="regexName" type="xsd:Name" />
<xsd:element ref="comment" />
</xsd:sequence>
<xsd:attribute name="level" type="xsd:string" />
...
<xsd:attributeGroup ref="RegexTypes">

<!-- error on next line's xsd:attribute, same for replacing with
element -->
<xsd:attribute name="nextRegexLink" type="regexName" minOccurs="0"
maxOccurs="unbounded" />
</xsd:attributeGroup>
</xsd:complexType>


</xsd:complexType>
<xsd:element name="comment" type="xsd:string">
</xsd:element>


and I get:
Warning 2 The element 'attributeGroup' in namespace
'http://www.w3.org/2001/XMLSchema' has invalid child element 'attribute' in
namespace 'http://www.w3.org/2001/XMLSchema'. List of possible elements
expected: 'annotation' in namespace 'http://www.w3.org/2001/XMLSchema'.
D:\data\Ieproj\Util\RegexDotNet\regex.xsd 34 8 Miscellaneous Files

Warning 1 The 'http://www.w3.org/2001/XMLSchema:attribute' element is not
supported in this context. D:\data\Ieproj\Util\RegexDotNet\regex.xsd 34 8
Miscellaneous Files




I tried another approach that seem to be acceptable to ms visual studio but
not to NetBean IDE 5.5:
<xsd:group name="RegexCollection">
<xsd:sequence>
<xsd:element name="favorite" type="xsd:string" />
..............

<xsd:element ref="comment" />
<xsd:element name="regexType" type="RegexTypes" />
<xsd:element name="nextRegexLink" type="regexName" minOccurs="0"
maxOccurs="unbounded" />

</xsd:sequence>
</xsd:group>
<xsd:complexType name="RegexTypes">
<xsd:sequence>
<xsd:element name="regexName" type="xsd:Name" />
<xsd:element ref="comment" />
</xsd:sequence>
.............


</xsd:complexType>

src-resolve: Cannot resolve the name 'regexName' to a(n) 'type definition'
component. [47]
XML validation finished.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top