I am trying to retrieve SQL data from multiple tables (SQl Server 2000) and present it in XML in the browser (result.aspx page). I am using "for xml explicit" to retrieve the data. But I am having trouble in displaying the data since I would have to valid
ate the xml against the dtd.
could anyone tell me how to validate the XML document and present it in the browser after I have retrieved the data ?
thanks!
- garfieldinstore
the dtd is as follows:
<!ELEMENT WebOrders(WebOrder*)>
<!ATTLIST WebOrders
NumberOfOrders CDATA #REQUIRED
>
<!ELEMENTWebOrder(Order, WebComment)>
<!ELEMENTWebComment (#CDATA)>
<!ELEMENT Order (
AddressInfo*,
Shipping?,
CreditCard?,
Comments?,
Item*,
Total,
)>
<!ATTLIST Order
id CDATA #REQUIRED
currency CDATA #REQUIRED
>
<!ELEMENT AddressInfo (Name,
Address1?,
Address2?,
City?,
State?,
Country?,
Zip?,
Phone?,
Email?,
Custom*
)>
<!ATTLIST AddressInfo
type (ship|bill) #REQUIRED
>
<!ELEMENT Name (First,
Last,
Full
)>
<!ELEMENT First (#PCDATA)>
<!ELEMENT Last (#PCDATA)>
<!ELEMENT Full (#PCDATA)>
<!ELEMENT Address1 (#PCDATA)>
<!ELEMENT Address2 (#PCDATA)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Country (#PCDATA)>
<!ELEMENT Zip (#PCDATA)>
<!ELEMENT Phone (#PCDATA)>
<!ELEMENT Email (#PCDATA)>
<!ELEMENT Custom (#PCDATA)>
<!ATTLIST Custom
name CDATA #REQUIRED
>
<!ELEMENT Shipping (#PCDATA)>
<!ELEMENT CreditCard (#PCDATA)>
<!ATTLIST CreditCard
type CDATA #REQUIRED
expiration CDATA #REQUIRED
>
<!ELEMENT Comments (#PCDATA)>
<!ELEMENT Item (
Code,
Quantity,
Unit-Price,
Description,
Option*,
)>
<!ATTLIST Item
num CDATA #IMPLIED
>
<!ELEMENT Code (#PCDATA)>
<!ELEMENT Quantity (#PCDATA)>
<!ELEMENT Unit-Price (#PCDATA)>
<!ELEMENT Description (#PCDATA)>
<!ELEMENT Option (#PCDATA)>
<!ATTLIST Option
name CDATA #REQUIRED
>
<!--
In an effort to programmatically access the Line items, we provide a canonical type attribute which will be one of the enumerated values listed below.
-->
<!ELEMENT Total (Line*)>
<!ELEMENT Line (#PCDATA)>
<!ATTLIST Line
type (GiftWrap|Discount|MiscAdjustment|
Coupon|GiftCertificate|Subtotal|
Shipping|Tax|Credit|Total) #IMPLIED
name CDATA #REQUIRED
notes CDATA #IMPLIED
>
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
You could read the XML into an XmlValidatingReader object and use that to
validate it before rendering it. See
http://msdn.microsoft.com/library/de...tingReader.asp
for more info.
Alternatively, you could use an XML schema instead of a DTD and add
annotations to the schema to map it to the data - SQLXML would then
automatically generate the appropriate FOR XML EXPLICIT query at runtime.
See
http://msdn.microsoft.com/library/de...tions_0gqb.asp
for more info.
Hope that helps,
Graeme
--
Graeme Malcolm
Principal Technologist
Content Master Ltd.
www.contentmaster.com
www.microsoft.com/mspress/books/6137.asp
"SqlJunkies User" <User@.-NOSPAM-SqlJunkies.com> wrote in message
news:OB2NPFuNEHA.2468@.TK2MSFTNGP11.phx.gbl...
> I am trying to retrieve SQL data from multiple tables (SQl Server 2000)
and present it in XML in the browser (result.aspx page). I am using "for xml
explicit" to retrieve the data. But I am having trouble in displaying the
data since I would have to validate the xml against the dtd.
> could anyone tell me how to validate the XML document and present it in
the browser after I have retrieved the data ?
> thanks!
> - garfieldinstore
> the dtd is as follows:
> <!ELEMENT WebOrders(WebOrder*)>
> <!ATTLIST WebOrders
> NumberOfOrders CDATA #REQUIRED
> <!ELEMENT WebOrder(Order, WebComment)>
> <!ELEMENT WebComment (#CDATA)>
> <!ELEMENT Order (
> AddressInfo*,
> Shipping?,
> CreditCard?,
> Comments?,
> Item*,
> Total,
> )>
> <!ATTLIST Order
> id CDATA #REQUIRED
> currency CDATA #REQUIRED
> <!ELEMENT AddressInfo (Name,
> Address1?,
> Address2?,
> City?,
> State?,
> Country?,
> Zip?,
> Phone?,
> Email?,
> Custom*
> )>
> <!ATTLIST AddressInfo
> type (ship|bill) #REQUIRED
> <!ELEMENT Name (First,
> Last,
> Full
> )>
> <!ELEMENT First (#PCDATA)>
> <!ELEMENT Last (#PCDATA)>
> <!ELEMENT Full (#PCDATA)>
> <!ELEMENT Address1 (#PCDATA)>
> <!ELEMENT Address2 (#PCDATA)>
> <!ELEMENT City (#PCDATA)>
> <!ELEMENT State (#PCDATA)>
> <!ELEMENT Country (#PCDATA)>
> <!ELEMENT Zip (#PCDATA)>
> <!ELEMENT Phone (#PCDATA)>
> <!ELEMENT Email (#PCDATA)>
> <!ELEMENT Custom (#PCDATA)>
> <!ATTLIST Custom
> name CDATA #REQUIRED
> <!ELEMENT Shipping (#PCDATA)>
> <!ELEMENT CreditCard (#PCDATA)>
> <!ATTLIST CreditCard
> type CDATA #REQUIRED
> expiration CDATA #REQUIRED
> <!ELEMENT Comments (#PCDATA)>
> <!ELEMENT Item (
> Code,
> Quantity,
> Unit-Price,
> Description,
> Option*,
> )>
> <!ATTLIST Item
> num CDATA #IMPLIED
> <!ELEMENT Code (#PCDATA)>
> <!ELEMENT Quantity (#PCDATA)>
> <!ELEMENT Unit-Price (#PCDATA)>
> <!ELEMENT Description (#PCDATA)>
> <!ELEMENT Option (#PCDATA)>
> <!ATTLIST Option
> name CDATA #REQUIRED
> <!--
> In an effort to programmatically access the Line items, we provide a
canonical type attribute which will be one of the enumerated values listed
below.
> -->
> <!ELEMENT Total (Line*)>
> <!ELEMENT Line (#PCDATA)>
> <!ATTLIST Line
> type (GiftWrap|Discount|MiscAdjustment|
> Coupon|GiftCertificate|Subtotal|
> Shipping|Tax|Credit|Total) #IMPLIED
> name CDATA #REQUIRED
> notes CDATA #IMPLIED
>
>
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.
No comments:
Post a Comment