[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] XSL embedded in XML
Subject: [xsl] XSL embedded in XML From: Gabriel Kleinoscheg <gabriel.kleinoscheg@xxxxxx> Date: Mon, 18 Apr 2011 14:16:28 +0200 |
Hello Everybody! I'm still struggling with the following XML and XSL files. In the first example I've separated the XML and the XSL: XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type='text/xsl' href='test02.xsl'?> <target xmlns="urn:asdf"> <title>This is the title</title> </target> XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:n="urn:asdf" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head> <title> <xsl:value-of select="n:target/n:title"/> </title> </head> <body> <h1> <center> <xsl:value-of select="n:target/n:title"/> </center> </h1> </body> </html> </xsl:template> <!--xsl:template match="xsl:stylesheet"/--> </xsl:stylesheet> The example above works quite well in every browser. Now comes the challenge - embedding the XSL into the XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type='text/xsl' href='#test'?> <!DOCTYPE target [<!ATTLIST xsl:stylesheet id ID #REQUIRED>]> <target xmlns="urn:asdf"> <xsl:stylesheet id="test" xmlns:n1="urn:asdf" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <!-- CDA document --> <xsl:template match="/"> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <title> <xsl:value-of select="n1:target/n1:title"/> </title> </head> <body> <h1> <center> <xsl:value-of select="n1:target/n1:title"/> </center> </h1> </body> </html> </xsl:template> <xsl:template match="xsl:stylesheet"/> </xsl:stylesheet> <title>This is the title</title> </target> I've tested this example - it doesn't show correctly in Firefox and IE but in Safari. Although when I check the generated source with WebDeveloper in Firefox I see the correct html-code. If I write <n1:target xmlns:n1="urn:asdf"> <n1:title> ... </n1:title> </n1:title> everything works perfectly. But why isn't it possible without the prefixes in the XML? Why does it work, if XML and XSL are separated but not when they are within one document? Hope you can help me. Thank you anyway. regards, Gabriel
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XQuery - Two if's in a fo, Liam R E Quin | Thread | Re: [xsl] XSL embedded in XML, Chris Maloney |
Re: [xsl] XQuery - Two if's in a fo, Florent Georges | Date | Re: [xsl] XSL embedded in XML, Chris Maloney |
Month |