xml reference problem

Discussion in 'XML' started by gg, Mar 28, 2007.

  1. gg

    gg Guest

    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.
    gg, Mar 28, 2007
    #1
    1. Advertising

  2. gg

    gg Guest

    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" <> wrote in message
    news:LOBOh.24713$x9.1300@edtnps89...
    > 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.
    >
    >
    gg, Mar 30, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page