aspose file tools*
The moose likes XML and Related Technologies and the fly likes xml and hyperlinks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml and hyperlinks" Watch "xml and hyperlinks" New topic
Author

xml and hyperlinks

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
Hi there,

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?

Alan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

I don't understand the question. Here's my sample XML document:
<?xml version="1.0" encoding="UTF-8">
<main>
<text>Hello, world</text>
<a href="www.someplace.com">www.someplace.com</a>
<text>Goodbye, world</text>
</main>
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?
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
Sorry, I guess I didn't give enough info.

My xml file has the following header:

<?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.

Alan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xml and hyperlinks
 
Similar Threads
XML XSL and hyperlink
what is the use of class attribute associated with a HTML element.
JLable as hyperlink
Query on url-pattern element of web.xml file ??
Read data to the xml file from the database?