13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Load always works synchronously, so when it returns, you can be sure that the load<strong>in</strong>gstep has been completed. You will not get from Load any return value that denotes thefailure or the success of the operation. When someth<strong>in</strong>g goes wrong with the Loadmethod, however, some exceptions are thrown. In particular, you will get aFileNotFoundException exception if you are po<strong>in</strong>t<strong>in</strong>g to a miss<strong>in</strong>g style sheet, and youwill get a more generic XsltCompileException exception if the XSLT script conta<strong>in</strong>serrors. An XsltCompileException exception provides you with a l<strong>in</strong>e position andnumber <strong>in</strong>dicat<strong>in</strong>g where the error occurred <strong>in</strong> the style sheet.Load<strong>in</strong>g the Style SheetThe <strong>in</strong>put style sheet can be loaded from four sources: a URL, an <strong>XML</strong> reader, anXPath document, or an XPath navigator. Whatever the source, the Load method firstexpresses it as an XPath navigator. As discussed <strong>in</strong> Chapter 6, an XPath navigatorrepresents a generic <strong>in</strong>terface able to navigate over any <strong>XML</strong>based, or <strong>XML</strong>-look<strong>in</strong>g,data store. The XPathNavigator class enables you to move from one node to the nextand to retrieve node-sets us<strong>in</strong>g XPath queries.The source style sheet is normalized to an XPath navigator mostly <strong>for</strong> per<strong>for</strong>mancereasons. The style sheet must be compiled and, given the compiler's architecture, anavigator is an extremely efficient object <strong>for</strong> per<strong>for</strong>m<strong>in</strong>g the task. Compil<strong>in</strong>g is a processthat simply excerpts <strong>in</strong><strong>for</strong>mation from the orig<strong>in</strong>al style sheet and stores it <strong>in</strong> handy datastructures <strong>for</strong> further use. The entire set of these data structures is said to be the stateof the XSLT processor. Figure 7-6 illustrates the flow of the Load method.Figure 7-6: The style sheet is first normalized to an XPath navigator and then compiled.Manag<strong>in</strong>g the Processor's StateThe style sheet compiler populates three <strong>in</strong>ternal data structures with the data readfrom the source. The compiled style sheet object shown <strong>in</strong> Figure 7-6 represents an255

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!