jasonJ
11-08-2008, 08:05 PM
I doubt it's a good place for such thing, but can't think of any better now.
Now, I've got an XML file in which one element contains some plain HTML tags:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="index.xsl" ?>
<doc>
<app>
<p>Blah blah <a href="http://someaddress">some address</a> blah</p>
<p>Blah blah blah again</p>
</app>
</doc>
As you may have noticed, I'm using XSLT to display this XML file as an XHTML.
Here's the xsl file (index.xsl):
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div>
<xsl:value-of select="doc/app" />
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The problem is, when I display the xml file in a browser, all standard HTML elements like <p> and <a> are stripped and the result is just plain text.
However, according to this W3C XML tutorial (http://www.w3schools.com/xml/xml_namespaces.asp), you can add a namespace to an xml element:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="index.xsl" ?>
<doc>
<app xmlns="http://www.w3.org/1999/xhtml">
<p>Blah blah <a href="http://someaddress">some address</a> blah</p>
<p>Blah blah blah again</p>
</app>
</doc>
The effect however is that the <app> element isn't displayed at all.
I'm hopeless, really. Don't know XML/XSLT that well. Can't work it out.
EDIT: solved (http://groups.google.com/group/jquery-en/browse_thread/thread/b06a8467afbcc209/d6ee2f8558aa4299?lnk=raot&pli=1).
Now, I've got an XML file in which one element contains some plain HTML tags:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="index.xsl" ?>
<doc>
<app>
<p>Blah blah <a href="http://someaddress">some address</a> blah</p>
<p>Blah blah blah again</p>
</app>
</doc>
As you may have noticed, I'm using XSLT to display this XML file as an XHTML.
Here's the xsl file (index.xsl):
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div>
<xsl:value-of select="doc/app" />
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The problem is, when I display the xml file in a browser, all standard HTML elements like <p> and <a> are stripped and the result is just plain text.
However, according to this W3C XML tutorial (http://www.w3schools.com/xml/xml_namespaces.asp), you can add a namespace to an xml element:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="index.xsl" ?>
<doc>
<app xmlns="http://www.w3.org/1999/xhtml">
<p>Blah blah <a href="http://someaddress">some address</a> blah</p>
<p>Blah blah blah again</p>
</app>
</doc>
The effect however is that the <app> element isn't displayed at all.
I'm hopeless, really. Don't know XML/XSLT that well. Can't work it out.
EDIT: solved (http://groups.google.com/group/jquery-en/browse_thread/thread/b06a8467afbcc209/d6ee2f8558aa4299?lnk=raot&pli=1).