
April 11th, 2011, 03:50 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 5
Time spent in forums: 2 h 42 m 12 sec
Reputation Power: 0
|
|
|
embed xsl
split from http://forums.devshed.com/showthread.php?t=77694 --requinix
Hello I'm new to this Forum!
I'm currently also trying to embed XSL directly into an XML file - so far so good. I also tried the examples mentioned above. My problem is the following. But first the sample code here:
Code:
<?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="W3 XSL Transformation">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<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>
The example works fine in Safari 5 but not in Firefox 4. Well in Firefox it shows "This is the title" twice, but without formatation. Interestingly, if I remove the xmlns="urn:asdf" and xmlns:n1="urn:asdf" everthing works quite fine - in Safari and Firefox. However nothing is presented if I write xmlns="urn:asdf" in the target-Tag and the xsl:stylesheet-Tag.
Anyway why is it necessary to define xmlns for the XML and the XSL even if it's the same? Why do I have to add ":n1" for the xmlns in the stylesheet? And why is there no problem at all, when I remove both xmlns instructions?
I would be grateful for any help. Thank you.
_gabe_
Last edited by requinix : April 11th, 2011 at 03:52 PM.
|