java qr code generator with logo Combining the XSLT and XML documents in Java

Generator QR Code in Java Combining the XSLT and XML documents

12.4 Combining the XSLT and XML documents
QR Code Creator In Java
Using Barcode creator for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications.
www.OnBarcode.com
Scanning QR Code In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Back on the client, we need to combine the XSLT and XML documents from the server. When using an XSLT transformation, we ll find that the browsers differ on how they combine the two documents. Therefore, we first check to see what method the browser supports in order to load and combine our two documents. Again we re using the ContentLoader object, introduced in chapter 3. It is contained in the external JavaScript file, net.js. This file does all of the work of determining how to send the information to the server, hiding any browserspecific code behind the easy-to-use wrapper object.
QR Code ISO/IEC18004 Maker In Java
Using Barcode generator for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications.
www.OnBarcode.com
Making Matrix Barcode In Java
Using Barcode maker for Java Control to generate, create Matrix image in Java applications.
www.OnBarcode.com
<script type="text/javascript" src="net.js"></script>
PDF417 Creator In Java
Using Barcode maker for Java Control to generate, create PDF 417 image in Java applications.
www.OnBarcode.com
Make Barcode In Java
Using Barcode generator for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Now we can begin the process of obtaining the server-side files and combining them on the client. In listing 12.7, the LoadXMLXSLTDoc() function is being called from the function GrabNumber() in listing 12.2. The function GrabNumber() passes in the values for the URL that generates the XML data, the XSL file, and
Encoding Code 3/9 In Java
Using Barcode drawer for Java Control to generate, create Code 39 image in Java applications.
www.OnBarcode.com
Rationalized Codabar Generation In Java
Using Barcode printer for Java Control to generate, create 2 of 7 Code image in Java applications.
www.OnBarcode.com
Live search using XSLT
Painting QR-Code In None
Using Barcode generator for Software Control to generate, create Denso QR Bar Code image in Software applications.
www.OnBarcode.com
QR Code JIS X 0510 Maker In Objective-C
Using Barcode creator for iPad Control to generate, create QR Code 2d barcode image in iPad applications.
www.OnBarcode.com
the output reference ID. With these three values, we are able to load the two documents and combine them when both have been completely loaded. After they have been loaded, we have to do some cross-browser coding in order to combine the XML and XSL files. You can see all of this happening in listing 12.7.
Code 39 Creation In Java
Using Barcode creation for Eclipse BIRT Control to generate, create Code-39 image in Eclipse BIRT applications.
www.OnBarcode.com
PDF 417 Encoder In None
Using Barcode encoder for Office Word Control to generate, create PDF 417 image in Office Word applications.
www.OnBarcode.com
Listing 12.7 LoadXMLXSLTDoc
Decoding Barcode In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Create Code 128 Code Set C In Java
Using Barcode creation for Android Control to generate, create Code 128 image in Android applications.
www.OnBarcode.com
var xmlDoc; Declare global var xslDoc; variables var objOutput; function LoadXMLXSLTDoc(urlXML,urlXSL,elementID){ xmlDoc=null; Set variables to null xslDoc=null; objOutput = document.getElementById( elementId); new net.ContentLoader(urlXML,onXMLLoad); new net.ContentLoader(urlXSL,onXSLLoad); }
Barcode Generation In Visual Basic .NET
Using Barcode generation for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Linear Maker In Visual Basic .NET
Using Barcode printer for VS .NET Control to generate, create 1D image in .NET framework applications.
www.OnBarcode.com
Reference output element Load XML and XSL files
Barcode Reader In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Generating Barcode In None
Using Barcode generation for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
function onXMLLoad(){ xmlDoc=this.req.responseXML; doXSLT(); } function onXSLLoad(){ xslDoc=this.req.responseXML; doXSLT(); }
Decode Code 128 Code Set C In VS .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Create UPC-A Supplement 5 In Visual Basic .NET
Using Barcode generation for VS .NET Control to generate, create GTIN - 12 image in VS .NET applications.
www.OnBarcode.com
Handle XML document
Handle XSL document
function doXSLT(){ Check for loaded documents if (xmlDoc==null || xslDoc==null){ return; } if (window.ActiveXObject){ objOutput.innerHTML=xmlDoc.transformNode(xslDoc); } else{ var xsltProcessor = new XSLTProcessor(); Transform xsltProcessor.importStylesheet(xslDoc); XML var fragment =xsltProcessor. document transformToFragment( xmlDoc,document); objOutput.innerHTML = ""; objOutput.appendChild(fragment); }
Combining the XSLT and XML documents
To simplify the client-side script, we need to declare three global variables b to hold three different objects. The first two variables, xmlDoc and xslDoc, are going to hold the XML and XSLT files returned from the server. The third variable, objOutput, holds the object reference to our DOM element where the results are to be inserted. With these variables defined, we can now build the function LoadXMLXSLTDoc(), which we invoked from the function GrabNumber(). Since we are loading two documents, we need a way to determine when they are both loaded. We do this by looking to see if the variables xmlDoc and xslDoc contain their respective documents. Before we start, we must set the variables to null c. This removes any data that may exist in the variables if this function is run more than once on the page. The output location for the results is set d by using the passed element ID from the function call. Now we call the ContentLoader e twice, once for the XML document and once for the XSL document. In each call, the ContentLoader will get the URL and then call another function to load the documents. onXMLLoad() f loads the returned XML results into our global variable xmlDoc and then calls the function doXSLT() for future processing. onXSLLoad() g loads the XSL document into the global variable xslDoc and also calls the doXSLT() function. Processing cannot continue until both documents have been loaded, and there is no way of knowing which will be loaded first, so the doXSLT() function first checks for that. It is called twice, once after the XML document is loaded and once after the XSL document is loaded. The first time it is called, one of our global variables is still set to null and we exit the function h. The next time it is called, the function will not exit since neither of the variables will be null. With both documents now loaded, we are able to perform the XSLT transformation i. Once the two documents are loaded, we need to transform the XML document with the XSLT. As you can see by looking at the code in the listing, there are two different ways to do this, depending on the browser. Internet Explorer uses transformNode(), whereas Mozilla uses the XSLTProcessor object. Let s examine these two different implementations of performing the transformation in greater detail.
Copyright © OnBarcode.com . All rights reserved.