Re: XSL Problems
"Nickolay Ponomarev" <[email protected]> Fri, 29 Dec 2006 15:43:14 +0300
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
You should read something on XML namespaces and working with them from DOM. In particular, you use createDocument wrong (see http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument ) and you should use createElementNS instead of setting xmlns:* attributes on elements. In general, I think it's pretty hard to generate an XSLT dynamically like this. Nickolay On 12/29/06, Leon Bezuidenhout <[email protected]> wrote: > Thank, I did not even notice that.... > > The thing is that the document is being constructed dynamically and to > create the node I do this: > > var > > var oNode = document.implementation.createDocument("","xsl:choose", > null).firstChild; > > oNode.setAttribute("xmlns:xsl", "http://www.w3.org/1999/XSL/Transform"); > > > Why are my nodes generated without the "xsl:" ? I know I am not setting the > namesoace in the proper manner, but this is the only way I have found that > displays the namespace in my XML. > > I'm still new to Mozilla, I have been working with Explorer for the past 4 > years, so please excuse the silly questions > > Thanks > > > "Nickolay Ponomarev" <[email protected]> wrote in message > news:[email protected]... > > On 12/29/06, Leon Bezuidenhout <[email protected]> wrote: > >> [Exception... "Component returns failure code: 0x80600001 > >> [nsIXSLTProcess.importStyleSheet]" > >> nsresult: "0x80600001 (<unkown>)" location: "JS frame :: > >> http://devmac1/csp/samples/wab/htmlcontrols/commonxml.js :: anonymous :: > >> line 49" data: no] > >> > > That's NS_ERROR_XSLT_PARSE_FAILURE (see > > http://silver.warwickcompsoc.co.uk/mozilla/misc/nserror). Did you > > check that your > > stylesheet is correct? > > > > It seems to me that you have a "<choose" element without a namespace. > > > > And iirc, you need a select="" attribute on <value-of/> (after putting > > that into right namespace too). I don't remember much about XSLT. > > > > Nickolay > > > >> My code looks as follows: > >> > >> var processor = new XSLTProcessor(); > >> processor.importStylesheet(stylesheet); > >> > >> And my style sheet looks like htis: > >> > >> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > >> <xsl:template match="/"> > >> <root> > >> <xsl:apply-templates select="/*/*"/> > >> </root> > >> </xsl:template> > >> <xsl:template match="*/*"> > >> <Record> > >> <xsl:attribute name="RecordNo"> > >> <xsl:value-of select="@rn"/> > >> </xsl:attribute> > >> <xsl:for-each id="foreach" select="node()"> > >> <choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > >> <when xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > >> test=".[nodeName() = 'f1']"> > >> <customerid> > >> <value-of > >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> > >> </customerid> > >> </when> > >> <when xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > >> test=".[nodeName() = 'f2']"> > >> <companyname> > >> <value-of > >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> > >> </companyname> > >> </when> > >> </choose> > >> </xsl:for-each> > >> </Record> > >> </xsl:template> > >> </xsl:transform> > >> > >> Thanks, > >> Leon > >> > >> > >> _______________________________________________ > >> dev-tech-xml mailing list > >> [email protected] > >> https://lists.mozilla.org/listinfo/dev-tech-xml > >> > > > _______________________________________________ > dev-tech-xml mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-tech-xml >