I'm working with a project that utilizes xml. Ordinarily, for every element within the xml file, a filter is applied to replace double quotes, less than and greater then symbols ( ", <, > ) with their appropriate html equivalants ( ", <, > ).
However, I wanted to make a small change. For one of the elements, I wanted to make it possible for a user to provide HTML markup for hyperlinks. Such as: <a href="www.someplace.com">www.someplace.com</a>
I'm not sure if this is even allowed. So for the heck of it, I eliminated the filter for the one element, applied HTML markup for a hyperlink, and when I display the xml in the browser the HTML markup is indeed hidden but link is not a link. When I place my cursor over it, the cursor doesn't change to the pointing finger, nor does it recognize it as a hyperlink. I can click on that thing til the cows come home and nothing happens. Or for this forum I guess I should say "til the moose come home".
So, can HTML markup for a hyperlink in xml be accomplished? If so, how?
And when I ask Firefox or IE to display that, they display just that and nothing else. No special treatment for the <a> element. And why should there be any special treatment for it? It doesn't have any special meaning in XML.
But what you describe is something different. So there must be some special way that you display it in the browser. Can you explain about that?
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="http://www.scholastictrackssandbox.ca/scholastic/stylesheets/schedule.xsl"?> <!DOCTYPE schedule SYSTEM "http://www.scholastictrackssandbox.ca/scholastic/dtds/schedules.dtd">
I'm using a stylesheet that looks like this:
As you can see, I'm just setting up a table with five headers for: date, time,location, event, and comments. All of these simply contain strings. However, for the comments column, if its string contains the hyperlink: <a href="www.someplace.com">www.someplace.com</a> then it would be nice if it displayed as a hyperlink that you can click on instead of strickly text.
Right, the fact that a transformation was happening is relevant information. Anyway, your code transforms <comments> elements like this:and since there's no template that specifically handles a <comments> element, the default processing for XSLT takes place. And the default processing (if I recall correctly) is to copy only the text nodes in the element. So it's not that the markup is "hidden", it's more that it is discarded. You could add a template that transforms a <comments> element by simply doing a full copy of it:
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
Free, earth friendly heat - from the CodeRanch trailboss