The XML is well-formed, but it may or may not validate depending on what you have in your DTD or schema (if you have one at all, which you should ). If you have a DTD/schema and the <a> element isn't in it, your XML file won't validate.
Originally Posted by bbolte
One thing you should know with this approach though is that the <a> element can be treated just like any other element/node in your XML file (meaning it can be accessed by XPath, etc). If you don't want this to happen, wrap the contents of your <article> element in a CDATA section, like so:
If you wrap it in a CDATA section you have to alter the stylesheet a little bit and use value-of instead of copy-of (since you don't want a copy of everything, you just want the value of the CDATA section). You also have to disable output escaping so the angle brackets of the links don't get turned into the encoded equivalents (& gt; and & lt; ) Here's the stylesheet that worked for me:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="content.xsl" type="text/xsl"?>
This is content with a link, <a href="http://www.mylink.com">click here</a>.
I think this method will work best actually, as opposed to the previous method, because it keeps your article content from getting mixed up in your XML data, and if you decide you want to use a DTD or Schema in the future you don't have to add any HTML elements into it. Hope this helps!
<?xml version="1.0" encoding="utf-8"?>
<xsl:output method="html" version="4.01" encoding="utf-8" />
<p><xsl:value-of disable-output-escaping="yes" select="content/article" /></p>