Web hosting mysql - Chapter 18 Extensible Markup Language (XML) 881 80
March 26th, 2008Chapter 18 Extensible Markup Language (XML) 881 80 81
Pages: 82
Media Type: 86
87
Chapter 18 Extensible Markup Language (XML) 881 80 81
Pages: 82
Media Type: 86
87
88 89 90 Fig. 18.24 Fig. 18.24Fig. 18FiFi.24g. 18.24g.18.24XSL document that transforms sorting.xml(Fig. 18.23) into XHTML. (Part 3 of 3.) Lines 25 26 create the title for the XHTML document. We use the ISBN of the book from attribute isbn and the contents of element title to create the title string ISBN 999-99999-9-X -Deitel s XML Primer. Element xsl:value-of selects the book element s isbnattribute. Lines 33 35 create a header element that contains the book s author. Because the context node (i.e., the current node being processed) is book, the XPath expression author/ lastName selects the author s last name, and the expression author/firstName selects the author s first name. Line 40 selects each element (indicated by an asterisk) that is a child of element frontMatter. Line 43 calls node-set function name to retrieve the current node s element name (e.g., preface). The current node is the context node specified in the xsl:for-each(line 40). Lines 53 54 sort chapters by number in ascending order. Attribute selectselects the value of context node chapter s attribute number. Attribute data-type with
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.
880 Extensible Markup Language (XML) Chapter 18 28 29
32 33
36 37
| 43 |
47 ( |
| 57 Chapter |
61 ( |
| 71 Appendix |
75 ( |
Fig. 18.24 Fig. 18.24Fig. 18FiFi.24g. 18.24g.18.24XSL document that transforms sorting.xml(Fig. 18.23) into XHTML. (Part 2 of 3.)
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.
Chapter 18 Extensible Markup Language (XML) 879 Performance Tip 18.1 Using Internet Explorer on the client to process XSLT documents conserves server resources by using the client s processing power (instead of having the server process XSLT documents for multiple clients). Line 1 of Fig. 18.23 contains the XML declaration. Recall that an XSL document is an XML document. Line 6 is the xsl:stylesheet root element. Attribute version specifies the version of XSLT to which this document conforms. Namespace prefix xslis defined and is bound to the XSLT URI defined by the W3C. When processed, lines 11 13 write the document type declaration to the result tree. Attribute method is assigned “xml”, which indicates that XML is being output to the result tree. Attribute omit-xmldeclaration is assigned “no”, which outputs an XML declaration to the result tree. Attribute doctype-system and doctype-public write the Doctype DTD information to the result tree. XSLT documents contain one or more xsl:template elements that specify which information is output to the result tree. The template on line 16 matches the source tree s document root. When the document root is encountered, this template is applied, and any text marked up by this element that is not in the namespace referenced by xslis output to the result tree. Line 18 calls for all the templates that match children of the document root to be applied. Line 23 specifies a templatethat matches element book. 1 2 3 4 5 6
Check Tomcat Web Hosting services for best quality webspace to host your web application.
878 Extensible Markup Language (XML) Chapter 18 1 2 3 4 5 6 7 8
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.
Chapter 18 Extensible Markup Language (XML) 877 6
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.
876 Extensible Markup Language (XML) Chapter 18 Line 53 Adds the Schema collection referenced by Schemasto the Schemas property. This property sets the Schema used to validate the document. The ValidationType property (line 56) is set to the ValidationType enumeration constant for Automatically identifying the Schema s type (i.e., XDR or XSD). Lines 59 60 register method ValidationError with ValidationEventHandler. Method ValidationError (lines 76 81) is called if the document is invalid or an error occurs, such as if the document cannot be found. Failure to register a method with ValidationEventHandler causes an exception to be thrown when the document is missing or invalid. Validation is performed node-by-node by calling the method Read (line 63). Each call to Readvalidates the next node in the document. The loop terminates either when all nodes have been validated successfully or a node fails validation. When validated against their respective Schemas, the XML documents in Fig. 18.16 and Fig. 18.18 validate successfully. Figure 18.21 and Fig. 18.22 list two XML documents that fail to conform to book.xdr and book.xsd, respectively. In Fig. 18.21, the extra titleelement in book(lines 19 22) invalidate the document. In Fig. 18.22, the extra titleelement in book(lines 7 10) invalidates the document. Although both documents are invalid, they are well formed. 1 2 3 4 5 6
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.
Chapter 18 Extensible Markup Language (XML) 875 48 // get validator 49 XmlValidatingReader validator = 50 new XmlValidatingReader( reader ); 51 52 // assign Schema(s) 53 validator.Schemas.Add( schemas ); 54 55 // set validation type 56 validator.ValidationType = ValidationType.Auto; 57 58 // register event handler for validation error(s) 59 validator.ValidationEventHandler += 60 new ValidationEventHandler( ValidationError ); 61 62 // validate document node-by-node 63 while ( validator.Read() ) ; // empty body 64 65 // check validation result 66 if ( valid ) 67 consoleLabel.Text = “Document is valid”; 68 69 valid = true; // reset variable 70 71 // close reader stream 72 validator.Close(); 73 } // end validateButton_Click 74 75 // event handler for validation error 76 private void ValidationError( object sender, 77 ValidationEventArgs arguments ) 78 { 79 consoleLabel.Text = arguments.Message; 80 valid = false; // validation failed 81 } // end ValidationError 82 } // end ValidationTest Fig. 18.20 Fig. 18.2FiFig. 18.20g. 18.20 Fig. 18.20 Schema-validation example. (Part 2 of 2.) Lines 45 46 create an XmlReader for the file that the user selected from filesComboBox. The XML document to be validated against a Schema contained in the XmlSchemaCollection must be passed to the XmlValidatingReader constructor (lines 49 50).
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.
874 Extensible Markup Language (XML) Chapter 18 (i.e., “book.xdr”). Line 29 calls method Add to add a W3C XML Schema. The first argument specifies the namespace URI (i.e., line 18 in Fig. 18.19) and the second argument indentifies the schema file (i.e., “book.xsd”). This is the Schema that is used to validate bookxsd.xml. 1 // Fig. 18.20: ValidationTest.cs 2 // Validating XML documents against Schemas. 3 4 using System; 5 using System.Windows.Forms; 6 using System.Xml; 7 using System.Xml.Schema; // contains Schema classes 8 9 // determines XML document Schema validity 10 public class ValidationTest : System.Windows.Forms.Form 11 { 12 private System.Windows.Forms.ComboBox filesComboBox; 13 private System.Windows.Forms.Button validateButton; 14 private System.Windows.Forms.Label consoleLabel; 15 private System.ComponentModel.Container components = null; 16 17 private XmlSchemaCollection schemas; // Schemas 18 private bool valid; // validation result 19 20 public ValidationTest() 21 { 22 InitializeComponent(); 23 24 valid = true; // assume document is valid 25 26 // get Schema(s) for validation 27 schemas = new XmlSchemaCollection(); 28 schemas.Add( “book”, “book.xdr” ); 29 schemas.Add( “http://www.deitel.com/booklist”, “book.xsd” ); 30 } // end constructor 31 32 // Visual Studio .NET generated code 33 34 [STAThread] 35 static void Main() 36 { 37 Application.Run( new ValidationTest() ); 38 } // end Main 39 40 // handle validateButton click event 41 private void validateButton_Click( object sender, 42 System.EventArgs e ) 43 { 44 // get XML document 45 XmlTextReader reader = 46 new XmlTextReader( filesComboBox.Text ); 47 Fig. 18.20 Fig. 18.2FiFig. 18.20g. 18.20 Fig. 18.20 Schema-validation example. (Part 1 of 2.)
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.
Chapter 18 Extensible Markup Language (XML) 873 18 19
Check Tomcat Web Hosting services for best quality webspace to host your web application.
872 Extensible Markup Language (XML) Chapter 18 ment must contain exactly one titleelement. The asterisk (*) in line 15 indicates that the Schema permits any number of bookelements in element books. We discuss how to validate bookxdr.xmlagainst book.xdrin Section 18.5.4. 18.5.3 W3C XML Schema4 In this section, we focus on W3C XML Schema5 the schema that the W3C created. XML Schema is a Recommendation (i.e., a stable release suitable for use in industry). Figure 18.18 shows a Schema-valid XML document named bookxsd.xml and Fig. 18.19 shows the W3C XML Schema document (book.xsd) that defines the structure for bookxsd.xml. Although Schema authors can use virtually any filename extension, W3C XML Schemas typically use the .xsd extension. We discuss how to validate bookxsd.xmlagainst book.xsdin the next section. 1 2 3 4 5 6
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.