Search completed in 1.22 seconds.
9 results for "transformtofragment":
Using the Mozilla JavaScript interface to XSL Transformations - XSLT: Extensible Stylesheet Language Transformations
Web › XSLT › Using the Mozilla JavaScript interface to XSL Transformations
onload() { processor.importStylesheet(testTransform); } XSLTProcessor.importStylesheet() requires one argument, a DOM Node. If that node is a document node, you can pass in a full XSL Transform or a literal result element transform, otherwise it must be an xsl:stylesheet or xsl:transform element. Transforming the document You can use the XSLTProcessor.transformToDocument() or XSLTProcessor.transformToFragment() methods to transform a document using the imported XSLT stylesheet. transformToDocument XSLTProcessor.transformToDocument() takes one argument, the source node to transform, and returns a new Document with the results of the transformation: var newDocument = processor.transformToDocument(domToBeTransformed); The resultant object depends on the output method of the stylesheet: html - HTM...
...This is handy because appending a fragment to another node transparently appends all the children of that fragment, and the fragment itself is not merged. Fragments are therefore useful for moving nodes around and storing them without the overhead of a full document object. XSLTProcessor.transformToF...
..., and returns a new Document with the results of the transformation: var newDocument = processor.transformToDocument(domToBeTransformed); The resultant object depends on the output method of the stylesheet: html - HTMLDocument xml - XMLDocument text - XMLDocument with a single root element <transformiix:result> with the text as a child transformToFragment You can also use XSLTProcessor.transformToFragment() which will return a DocumentFragment node. ...
...And 2 more matches
JavaScript/XSLT Bindings - XSLT: Extensible Stylesheet Language Transformations
Web › XSLT › XSLT JS interface in Gecko › JavaScript XSLT Bindings
If ...
...de = xmlRef.importNode(myNode, true); // add the cloned DOM into the XML document xmlRef.appendChild(clonedNode); Once the stylesheet has been imported, XSLTProcessor has to perform two methods for the actual transformation, namely XSLTProcessor.transformToDocument() and XSLTProcessor.transformToFragment(). XSLTProcessor.transformToDocument() returns a full XML document while XSLTProcessor.transformToFragment() returns a document fragment that can be easily added to an existing document. Both take in the XML document as the first parameter that will be transformed. XSLTProcessor.transformToFragment() requires a second parameter, namely the document object that will own the generated fragment. If the generated fragment will be inserted into the current HTML document, passing in document is enough. Fig...
...XML Soup' While you can use IE loadXML method to load a string containing XML you have to perform some tweaking and tuning to do the same in Mozilla. You must use the DomParser.no to create any document, as this is handled by the DomParser. var parser = new DOMParser(); var doc = parser.parseFromString(aStr, "text/xml"); Figure 3 : Performing the transformation var fragment = xsltProcessor.transformToFragment(xmlRef, document); ...
Connecting to Remote Content - Archive of obsolete content
Archive › Add-ons › Overlay Extensions › XUL School › Connecting to Remote Content
In this example code, the first child of the XUL document is appended to a XUL element after the transformation. request.onload = function(aEvent) {...
...In this example code, the first child of the XUL document is appended to a XUL element after the transformation. ...
Migrate apps from Internet Explorer to Mozilla - Archive of obsolete content
Archive › Mozilla › Migrate apps from Internet Explorer to Mozilla
sformations in memory. You can do this using the global XSLTProcessor JavaScript object. XSLTProcessor requires you to load the XML and XSLT files, because it needs their DOM documents. The XSLT document, imported by the XSLTProcessor, allows you to manipulate XSLT parameters. XSLTProcessor can generate a standalone document using transformToDocument(), or it can create a document fragment using transformToFragment(), which you can easily append into another DOM document. Below is an example: var xslStylesheet; var xsltProcessor = new XSLTProcessor(); // load the xslt file, example1.xsl var myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET", "example1.xsl", false); myXMLHTTPRequest.send(null); // get the XML document and import it xslStylesheet = myXMLHTTPRequest.responseXML; xsltProce...
...ust be transformed; that document is then passed to the transformToDocument method of XSLTProcessor. Table 8 features a list of XSLTProcessor methods. Table 8. XSLTProcessor methods Method Description void importStylesheet(Node styleSheet) Imports the XSLT stylesheet. The styleSheet argument is the root node of an XSLT stylesheet's DOM document. DocumentFragment transformToFragment(Node source, Document owner) Transforms the Node source by applying the stylesheet imported using the importStylesheet method and generates a DocumentFragment. owner specifies what DOM document the DocumentFragment should belong to, making it appendable to that DOM document. Document transformToDocument(Node source) Transforms the Node source by applying the stylesheet imported usi...
nsIXSLTProcessor
Mozilla › Tech › XPCOM › Reference › Interface › nsIXSLTProcessor
This will make the processor use the default-value for all parameters as specified in the stylesheet. void clearParameters(); Parameters None. getParameter() Gets a parameter if previously set by setParameter(). Returns null otherwise. nsIVariant getParameter( in...
...f the XSLT parameter. localName The local name of the XSLT parameter. value The new value of the XSLT parameter. transformToDocument() Transforms the node source applying the stylesheet imported by importStylesheet(). nsIDOMDocument transformToDocument( in nsIDOMNode source ); Parameters source The node to be transformed. Return value An Document containing the result of the transformation. transformToFragment() Transforms the node source applying the stylesheet imported by importStylesheet(). The created fragment will be owned by the specified output document. nsIDOMDocumentFragment transformToFragment( in nsIDOMNode source, in nsIDOMDocument output ); Parameters source The node to be transformed. output The document to own the returned document fragment. Return value A DocumentFragment contain...
Basic Example - XSLT: Extensible Stylesheet Language Transformations
Web › XSLT › XSLT JS interface in Gecko › Basic Example
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> The example loads using synchronous XMLHTTPRequest both the .xsl (xslStylesheet) and the .xml (xmlDoc) files into memory. The .xsl file is then imported (xsltProcessor.importStylesheet(xslStylesheet)) and the transformation run (xsltProcessor.transformToFragment(xmlDoc, document)). This allows fetching of data after the page has been loaded, without initiating a fresh page load. Figure 6 : Example var xslStylesheet; var xsltProcessor = new XSLTProcessor(); var myDOM; var xmlDoc; function Init(){ // load the xslt file, example1.xsl var myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET", "example1.xsl", false); myXMLHTTPReque...
...ET", "example1.xsl", false); myXMLHTTPRequest.send(null); xslStylesheet = myXMLHTTPRequest.responseXML; xsltProcessor.importStylesheet(xslStylesheet); // load the xml file, example1.xml myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET", "example1.xml", false); myXMLHTTPRequest.send(null); xmlDoc = myXMLHTTPRequest.responseXML; var fragment = xsltProcessor.transformToFragment(xmlDoc, document); document.getElementById("example").innerHTML = ""; myDOM = fragment; document.getElementById("example").appendChild(fragment); } ...
XSL Transformations in Mozilla FAQ - Web APIs
Web › API › XSLTProcessor › XSL Transformations in Mozilla FAQ
cts the expectations of the user. Thus, using media in <?xml-stylesheet ?> is strongly discouraged. Future builds might only load an XSLT stylesheet if media is not specified, or if the specified media include screen. This does not affect CSS stylesheets loaded from the generated DOM, those honor media just like in pages without XSLT. How do I do transformNode? There is transformToDocument and transformToFragment starting with Mozilla 1.2 final, see Using the Mozilla JavaScript interface to XSL Transformations. Why does Internet Explorer require a different XSLT namespace than Mozilla? IE up to version 6 required a deprecated namespace of a XSLT working draft, please update to Mozilla ;-), IE6+ or MSXML3+, as it is fixed there. As the differences between XSLT1.0 and the IE implementation of that WD are ...
XSLTProcessor - Web APIs
Web › API › XSLTProcessor
ents. Syntax The constructor has no parameters. new XSLTProcessor() Methods [Throws] void XSLTProcessor.importStylesheet(Node styleSheet) Imports the XSLT stylesheet. If the given node is a document node, you can pass in a full XSL Transform or a literal result element transform; otherwise, it must be an <xsl:stylesheet> or <xsl:transform> element. [Throws] DocumentFragment XSLTProcessor.transformToFragment(Node source, Document owner) Transforms the node source by applying the stylesheet imported using the XSLTProcessor.importStylesheet() function. The owner document of the resulting document fragment is the owner node. [Throws] Document XSLTProcessor.transformToDocument(Node source) Transforms the node source applying the stylesheet given importing using the XSLTProcessor.importStylesheet() f...
Advanced Example - XSLT: Extensible Stylesheet Language Transformations
Web › XSLT › XSLT JS interface in Gecko › Advanced Example
we append xmlRef.appendChild(clonedNode); // set the sorting parameter in the XSL file var sortVal = xsltProcessor.getParameter(null, "myOrder"); if (sortVal == "" || sortVal == "descending") xsltProcessor.setParameter(null, "myOrder", "ascending"); else xsltProcessor.setParameter(null, "myOrder", "descending"); // initiate the transformation var fragment = xsltProcessor.transformToFragment(xmlRef, document); // clear the contents document.getElementById("example").innerHTML = ""; myDOM = fragment; // add the new content from the transformation document.getElementById("example").appendChild(fragment) } // XSL Stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xm...