Jun 9, 2005 #1 acsooley Programmer Joined Nov 13, 2002 Messages 32 Location CA Is their a way in JSP to merger 2 xsl files together before you that format the merged xsl with xml to display the result?
Is their a way in JSP to merger 2 xsl files together before you that format the merged xsl with xml to display the result?
Jun 9, 2005 #2 CubeE101 Programmer Joined Nov 19, 2002 Messages 1,492 Location US See here: http://www.java2s.com/ExampleCode/JSP-JSTL/JSPParsingusingtheDOM.htmor http://www.java2s.com/ExampleCode/JSP-JSTL/JSPParsingusingtheDOMandJSTL.htmOn how to use DOM with JSP (again, I don't use JSP...) Then use it, as I mentioned in the other thread (thread426-1073337) to either import/include or merge the XSLs... The standard DOM functions you need to work with are... selectSingleNode(XpathPattern) appendChild(Node) cloneNode(True) createElement(tagname) You typically use like this... Load File: Code: var xslDom1; xslDom1 = new ActiveXObject("Microsoft.XMLDOM"); xslDom1.load("SomeXSL.xsl"); Create Element: (creates <xsl:include href="NEW-URL/text.xsl" />) Code: var Elem1; Elem1 = xslDom1.createElement('xsl:include'); Elem1.attributes.setNamedItem('href').text = 'NEW-URL/text.xsl'; Get Existing Element: (finds <xsl:template name="temp">...</xsl:template>) Code: var Elem2; Elem2 = xslDom1.selectSingleNode('//xsl:template[@name == "temp"').cloneNode(true); Append Element To xslDom2: (xslDom2 created same way as xslDom1) Code: xslDom2.DocumentElement.appendChild(Elem1); xslDom2.DocumentElement.appendChild(Elem2); Then, you could load an XML file into a new DOM, and transform it... (either to a string, or new Dom object) Code: var newText, newDom; newText = xmlDom.transformNode(xslDom2); xmlDom.transformNodeToObject(xslDom3, newDom); It is VERY possible that there are errors in the above code examples, but they should be a good generalization of what you need to do... Hope this was a litle help... -Josh Visit My Site PROGRAMMER: Red-eyed, mumbling mammal capable of conversing with inanimate objects. Upvote 0 Downvote
See here: http://www.java2s.com/ExampleCode/JSP-JSTL/JSPParsingusingtheDOM.htmor http://www.java2s.com/ExampleCode/JSP-JSTL/JSPParsingusingtheDOMandJSTL.htmOn how to use DOM with JSP (again, I don't use JSP...) Then use it, as I mentioned in the other thread (thread426-1073337) to either import/include or merge the XSLs... The standard DOM functions you need to work with are... selectSingleNode(XpathPattern) appendChild(Node) cloneNode(True) createElement(tagname) You typically use like this... Load File: Code: var xslDom1; xslDom1 = new ActiveXObject("Microsoft.XMLDOM"); xslDom1.load("SomeXSL.xsl"); Create Element: (creates <xsl:include href="NEW-URL/text.xsl" />) Code: var Elem1; Elem1 = xslDom1.createElement('xsl:include'); Elem1.attributes.setNamedItem('href').text = 'NEW-URL/text.xsl'; Get Existing Element: (finds <xsl:template name="temp">...</xsl:template>) Code: var Elem2; Elem2 = xslDom1.selectSingleNode('//xsl:template[@name == "temp"').cloneNode(true); Append Element To xslDom2: (xslDom2 created same way as xslDom1) Code: xslDom2.DocumentElement.appendChild(Elem1); xslDom2.DocumentElement.appendChild(Elem2); Then, you could load an XML file into a new DOM, and transform it... (either to a string, or new Dom object) Code: var newText, newDom; newText = xmlDom.transformNode(xslDom2); xmlDom.transformNodeToObject(xslDom3, newDom); It is VERY possible that there are errors in the above code examples, but they should be a good generalization of what you need to do... Hope this was a litle help... -Josh Visit My Site PROGRAMMER: Red-eyed, mumbling mammal capable of conversing with inanimate objects.