Subject: Re: XSL Filename From: "Kent Fitch" <kent.fitch@xxxxxxxxxxxx> Date: Mon, 15 Feb 1999 14:55:22 +1100 |
Shinichiro HAMADA <shinichiro.hamada@xxxxxxxxxxxxx> wrote: >I am now using XML and XSL with IE5b2. XSL is used for transforming the XML >to HTML. I want to embed the filename(URL) of XSL into the HTML, but I have >no idea to do so finally, though If that was CSS, i could be easily obtained >with DHTML object mode. For instance, I searched the solution in XML-DOM or >XSL methods. the process to embed XSL filaneme may be done at any steps >before generating HTML. Are there any way to achieve it? Please help me. If you are asking how to associate an XSL file with an XML (not HTML) file, you can use a processing instruction like this: <?xml:stylesheet type="text/xsl" href="/stylesheets/demo.xsl" ?> Under IE5b2 at least, when a client retrieves the XML file containing this processing instruction the client will then ask the server for "/stylesheets/demo.xsl" and apply that stylesheet to the XML document and render the results. If you want to apply the stylesheet yourself (on the server, maybe as part of an ASP script running under IIS using the MS DOM), you need to extract the name from the PI - I don't know whether there is a neat way to search for PI's, but this bit of javascript works for me: ... var doc = Server.CreateObject("Microsoft.XMLDOM"); doc.load(sourceFile); if (doc.parseError.errorCode != 0) ... // error processing // assumes stylesheet PI's will be represented under the doc node var ssList = doc.childNodes ; for (var i=0;i<ssList.length;i++) { var ss = ssList.item(i) ; if ((ss.nodeType == 7) // 7 means 'PI' && (ss.nodeName == "xml:stylesheet")) { // nodeValue should contain something like: // href="/stylesheets/demo.xsl" var ssName = ss.nodeValue.replace(/^.*href="/,"").replace(/".*$/,"") ; ... // if valid, so something with the stylesheet, which // may be not a local file ref - it can be any URL! // Worry about getting multiple (or no) stylesheet PI's } } Kent Fitch Ph: +61 2 6276 6711 ITS CSIRO Canberra Australia kent.fitch@xxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
XSL Filename, Shinichiro HAMADA | Thread | RE: XSL Filename, Shinichiro HAMADA |
Re: CSS and XSL, Frank Boumphrey | Date | RE: CSS and XSL, Jelks Cabaniss |
Month |