14: Publishing Information Using SQLXML in .NET

Making Data Matrix in .NET 14: Publishing Information Using SQLXML

14: Publishing Information Using SQLXML
Data Matrix 2d Barcode Recognizer In VS .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in .NET framework applications.
Drawing DataMatrix In .NET Framework
Using Barcode maker for VS .NET Control to generate, create Data Matrix ECC200 image in .NET framework applications.
Make="Toshiba" Model="Portege 7020CT"> <EqType EqType="Desktop"/> </Equipment> <Equipment EquipmentId="2" Make="Sony" Model="Trinitron 17XE"> <EqType EqType="Monitor"/> </Equipment> <Equipment EquipmentId="6" Make="NEC" Model="V90"> <EqType EqType="Desktop"/> </Equipment> ...
Decoding Data Matrix 2d Barcode In VS .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in VS .NET applications.
Bar Code Creator In .NET Framework
Using Barcode encoder for Visual Studio .NET Control to generate, create bar code image in .NET applications.
The XSL file shown in the following code listing describes how the XML file is converted:
Scanning Barcode In .NET
Using Barcode reader for .NET Control to read, scan read, scan image in .NET framework applications.
Data Matrix ECC200 Generation In Visual C#.NET
Using Barcode generator for .NET framework Control to generate, create ECC200 image in .NET applications.
< xml version='1.0' encoding='UTF-8' > <xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl' > <xsl:template match = '*'> <xsl:apply-templates /> </xsl:template> <xsl:template match = 'Equipment'> <TR> <TD><xsl:value-of select = '@EquipmentId' /></TD> <TD><xsl:value-of select = '@Make' /></TD> <TD><xsl:value-of select = '@Model' /></TD> <TD><xsl:value-of select = './EqType/@EqType' /></TD> </TR> </xsl:template> <xsl:template match = '/'> <HTML> <HEAD> <title>Equipment</title> </HEAD> <BODY> <TABLE border = "1" width="100%"> <TR><TH colspan="4" bgcolor="#000000"> <p align="left"><font color="#FFFFFF" face="Arial"> <b>Equipment</b> </font>
ECC200 Generator In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
Create Data Matrix In Visual Basic .NET
Using Barcode creator for .NET Control to generate, create ECC200 image in .NET framework applications.
SQL Server 2000 Stored Procedure & XML Programming
Bar Code Generation In .NET
Using Barcode maker for .NET framework Control to generate, create bar code image in .NET framework applications.
Code 39 Encoder In .NET Framework
Using Barcode generation for .NET framework Control to generate, create ANSI/AIM Code 39 image in VS .NET applications.
</p> </TH></TR> <TR> <TH align="left" bgcolor="#C0C0C0"> <b><font face="Arial" size="2"> Equipment ID </font></b> </TH> <TH align="left" bgcolor="#C0C0C0"> <b><font face="Arial" size="2"> Make </font></b> </TH> <TH align="left" bgcolor="#C0C0C0"> <b><font face="Arial" size="2"> Model </font></b> </TH> <TH align="left" bgcolor="#C0C0C0"> <b><font face="Arial" size="2"> Equipment Type </font></b> </TH> </TR> <xsl:apply-templates select = 'root' /> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet>
Matrix 2D Barcode Printer In .NET Framework
Using Barcode creation for .NET framework Control to generate, create Matrix Barcode image in .NET framework applications.
Uniform Symbology Specification Codabar Creator In Visual Studio .NET
Using Barcode generation for .NET framework Control to generate, create Codabar image in Visual Studio .NET applications.
You can distinguish two segments within the XSL file. The last xsl:template match = '/' element defines the static part of the HTML page. It consists of the <HEAD> and <BODY> tags of the HTML page and the definition of the table (using the <TABLE> tag). Because of the match = '/' attribute, the described transformation is performed on the root node of the XML document. The second xsl:template match = 'Equipment' element is applied to each element node called 'Equipment'. Each node is converted to a row within an HTML table (using row <TR> and column <TD> tags):
Drawing Code-39 In Objective-C
Using Barcode creator for iPhone Control to generate, create Code39 image in iPhone applications.
Making Bar Code In Java
Using Barcode creator for Java Control to generate, create bar code image in Java applications.
<xsl:template match = 'Equipment'> </TR> <TD><xsl:value-of select = '@EquipmentId' /></TD>
Recognizing Code 3/9 In Visual C#.NET
Using Barcode reader for .NET Control to read, scan read, scan image in .NET applications.
UPC-A Supplement 2 Printer In None
Using Barcode generator for Software Control to generate, create UPC Symbol image in Software applications.
14: Publishing Information Using SQLXML
Print ECC200 In Java
Using Barcode generation for Android Control to generate, create Data Matrix image in Android applications.
Generating EAN13 In Objective-C
Using Barcode generation for iPad Control to generate, create UPC - 13 image in iPad applications.
<TD><xsl:value-of select = '@Make' /></TD> <TD><xsl:value-of select = '@Model' /></TD> <TD><xsl:value-of select = 'EqType/@EqType' /></TD> </TR> </xsl:template>
Create Barcode In .NET
Using Barcode printer for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Making Bar Code In None
Using Barcode generator for Software Control to generate, create bar code image in Software applications.
The xsl:value-of elements define the source from which the parser obtains the values for the table cells. Recall that in the XPath section in the previous chapter, '@EquipmentId' referred to an attribute called EquipmentId (not a T-SQL local variable). The last node reference ('EqType/@EqType') is most interesting. It first points to a child node named EqType and then to its attribute named EqType. To execute the template file, you can specify the following URL:
http://localhost/asset/template/ListEquipmentWithXSL.xml
Unfortunately, Internet Explorer displays HTML code, as shown in Figure 14-12. To see how everything works together, you must prompt Internet Explorer to treat the content received from the web server as an HTML file rather than an XML file.
Figure 14-12
HTML code obtained using an XML template with XSL
SQL Server 2000 Stored Procedure & XML Programming
You must specify an additional parameter (contenttype=text/html) when you specify the URL:
http://localhost/asset/template/ListEquipmentWithXSL.xml contenttype=text/html
You can see the result in Figure 14-13.
Using Schemas and XPath Queries
The sql:XPath-query element of the template is used to specify XPath query expressions and mapping schema against which the XPath query expression should be executed. I will not describe mapping schemas until the next section, so I will demonstrate XPath queries in this section on the simplest possible schema. If you execute a simple Select statement with a For XML clause that contains an XMLData option against the Equipment table,
Select EquipmentId, Make, Model from Equipment For XML auto, XMLData
Figure 14-13
HTML page as a result of XSL transformation
14: Publishing Information Using SQLXML
you get an inline XDR schema at the beginning of the XML document:
<Schema name="Schema" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <ElementType name="Equipment" content="empty" model="closed"> <AttributeType name="EquipmentId" dt:type="i4"/> <AttributeType name="Make" dt:type="string"/> <AttributeType name="Model" dt:type="string"/> <attribute type="EquipmentId"/> <attribute type="Make"/> <attribute type="Model"/> </ElementType> </Schema> <Equipment xmlns="x-schema:#Schema" EquipmentId="1" Make="Toshiba" Model="Portege 7020CT"/> ...
To get a proper mapping schema in this case, you need to extract the schema into a separate file and add another namespace to it (xmlns:sql="urn:schemasmicrosoft-com:xml-sql"):
<Schema name="Schema" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:sql="urn:schemas-microsoft-com:xml-sql"> <ElementType name="Equipment" content="empty" model="closed"> <AttributeType name="EquipmentId" dt:type="i4"/> <AttributeType name="Make" dt:type="string"/> <AttributeType name="Model" dt:type="string"/> <attribute type="EquipmentId"/> <attribute type="Make"/> <attribute type="Model"/> </ElementType> </Schema>
NOTE
This is not the only operation usually needed to create a mapping schema. It is successful in this case only because the target XML document is so simple. The following section explores the details of mapping a schema.
Now it is possible to create a template file to use the XPath query to get information using this schema:
Copyright © OnBarcode.com . All rights reserved.