Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / August 2007

Tip: Looking for answers? Try searching our database.

How do I access a reference in XmlSchema?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 30 Jun 2007 23:58 GMT
I have an xsd:
    <xsd:element name="comment" type="xsd:string">
        <xsd:annotation>
            <xsd:documentation>hi there</xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    <xsd:complexType name="PurchaseOrderType">
        <xsd:sequence>
            <xsd:element name="shipTo" type="USAddress"/>
            <xsd:element name="billTo" type="USAddress"/>
            <xsd:element ref="comment" minOccurs="0"/>
            <xsd:element name="items" type="Items"/>
        </xsd:sequence>
        <xsd:attribute name="orderDate" type="xsd:date"/>
    </xsd:complexType>

that I load into an XmlSchema object. One of the inner elements uses a
ref="comment" instead of a name=. Do I need to then walk the entire tree in
the XmlSchema to get the reference, or walk all the top level elements, or is
there a property I can use to access it directly?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

John Saunders [MVP] - 01 Jul 2007 02:15 GMT
>I have an xsd:
> <xsd:element name="comment" type="xsd:string">
[quoted text clipped - 18 lines]
> is
> there a property I can use to access it directly?

ref can only refer to global elements. You only need to look at the
XmlSchemaSet.GlobalElements collection to see the possible root elements.
Signature

John Saunders [MVP]

David Thielen - 01 Jul 2007 19:12 GMT
Worked great - thanks.

I assume from the documentation when I see this that I ignore the properties
in the initial element (except for min/max/id if set) and instead the
reference is the element at this position and the reference then gives me any
attributes and child elements???

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> >I have an xsd:
> > <xsd:element name="comment" type="xsd:string">
[quoted text clipped - 21 lines]
> ref can only refer to global elements. You only need to look at the
> XmlSchemaSet.GlobalElements collection to see the possible root elements.
WenYuan Wang [MSFT] - 03 Jul 2007 11:17 GMT
Hello Dave
Thanks for John's idea.
XmlSchemaSet.GlobalElements is the best way to search the reference.

The schema you posted in newsgroup is equal to
<xsd:complexType name="PurchaseOrderType">
        <xsd:sequence>
            <xsd:element name="shipTo" type="USAddress"/>
            <xsd:element name="billTo" type="USAddress"/>

            <xsd:element name="comment" type="xsd:string" minOccurs="0">
                    <xsd:annotation>
                        <xsd:documentation>hi there</xsd:documentation>
                    </xsd:annotation>
            </xsd:element>

            <xsd:element name="items" type="Items"/>
        </xsd:sequence>
        <xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>

If you get the reference, it will tell you all child element and
attributes. However, please don't forget the attribute in the initial
element. (such as the minOccurs="0" in the current case)

Hope this helps.
Sincerley,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
hgbjxeiluw - 26 Aug 2007 03:26 GMT
Hello! Good Site! Thanks you! jkhrpezklonvxx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.