Subject: RE: [xsl] Question about MS setProperty method From: Chuck White <chuckwh@xxxxxxxxxxx> Date: Wed, 23 Oct 2002 09:11:44 -0700 |
That's great, thanks Marrow. For the long term that opens up a whole new world for the app in question! Cheers, Chuck White ------------------------- Author, Mastering XSLT, Sybex Books Co-Author, Mastering XML Premium Edition, Sybex Books http://www.javertising.com/webtech/ > Hi Chuck, > > Any namespaces that you want to select against using XPath (in > selectSingleNode or selectNodes) have to be declared to the DOM (even > the default namespaces used in the XML). > > To declare the namespaces to the DOM you need to use the setProperty > method again, e.g. > > MyDOM.setProperty("SelectionNamespaces","xmlns:my='urn:whatever'") > > (where the URI matches the one in the input XML). > > If you have default namespaces in the XML you need to give them an > arbitrary prefix when declaring the namespace to the DOM. > > > Hope this helps > Marrow, Microsoft XML MVP > http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger) > http://www.topxml.com/Xselerator > > > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Chuck White > Sent: 23 October 2002 15:37 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Question about MS setProperty method > > > My apologies in advance for this vendor-specific question, but this is > really the best place to ask. > > In creating a client-side web app that calls templates dynamically, I > have found that I can successfully change the name of a called template > dynamically, but I have to use a match pattern in the selectSingleNode > method for some reason. If I try to use the setProperty method to set > the language to XPath, I get an error message saying "Reference to > undeclared namespace prefix xsl" > > However, if I leave it off and go with the default language (XSL > Patterns, according to the MSDN site), it works fine. > > So this works fine: > > <script language="JScript"> > function chngNode(xPath, xValue) { > xmlDoc = document.XMLDocument; > xslDoc = document.XSLDocument; > var matchString = xslDoc.selectSingleNode(xPath); > matchString.text = xValue; > > output.innerHTML = xmlDoc.documentElement.transformNode(xslDoc); > > //This resets the call-template name to "content" > //Otherwise, the preceding change > // kills it, and the script looks for it, > // so leaving it off results in an error > matchString.text = "content"; > > } > </script> > > But this doesn't: > > <script language="JScript"> > function chngNode(xPath, xValue) { > xmlDoc = document.XMLDocument; > xslDoc = document.XSLDocument; > // this next line is the offendor > // and results in the namespace error > xslDoc.setProperty("SelectionLanguage", "XPath"); > var matchString = xslDoc.selectSingleNode(xPath); > matchString.text = xValue; > > output.innerHTML = xmlDoc.documentElement.transformNode(xslDoc); > > //This resets the call-template name to "content" > //Otherwise, the preceding change > // kills it, and the script looks for it, > // so leaving it off results in an error > matchString.text = "content"; > > } > </script> > > Anyone out there understand what is happening under the hood to make the > second fail? It doesn't matter for the app I'm working on, since it > works, but being relegated to selecting only patterns makes it harder to > pass parameters client-side when complex interactions are involved. > > My guess is that somehow since you're changing the language to XPath, > you're basically removing the wired-in xsl namespace, but that's purely > a guess. > > Thanks in advance! > > Cheers, > > Chuck White > ------------------------- > Author, Mastering XSLT, Sybex Books > Co-Author, Mastering XML Premium Edition, Sybex Books > http://www.javertising.com/webtech/ > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Question about MS setProp, Marrow | Thread | [xsl] sort + current() - bug in Mic, WATKIN-JONES,ADAM (H |
[xsl] Newbie, question about loopin, Erick Todd | Date | [xsl] work with xml elements throug, Ming Yu |
Month |