aspose file tools*
The moose likes XML and Related Technologies and the fly likes URL conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "URL conversion" Watch "URL conversion" New topic
Author

URL conversion

joseph cooper
Ranch Hand

Joined: Nov 08, 2005
Posts: 44
I am being passed a text version of an URL address. This address prints on the worksheet. I need to change the code to activate the address on the worksheet when selected.

I have been trying to figure out where is the best location to make the change. Do I convert the address to an URL address in the java code and then display it or do I continue to pass the text version of the address to the xslt code and make the conversion there?

java code:
//millmanlink = "http://www.google.com/";
Element millmanlink = xmlDoc.createElement("millmanlink");
millmanlink.appendChild(xmlDoc.createTextNode memberOfClientList.millmanLink));
client.appendChild(millmanlink);

and some xslt code that prints this address on the worksheet

xslt code:
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<TBODY>
<TR>
<TD width="99%">
<font color="blue">
<xsl:value-of select="millmanlink"/> <!-- target=_blank -->
</font>
</TD>
</TR>
</TBODY>
</table>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

There's a lot of things I don't understand about your post.

First, what do you mean by "a text version of an URL address"? URLs don't have versions, they are just strings of characters. From your code it appears you have a string, so okay, you've got a URL in that string.

Second, what's this "worksheet" thing? It appears you're generating HTML, so is it a web page? And what do you mean by "convert the address to a URL address"? I'm guessing you might want the URL to appear as a hyperlink in your web page. If that's the case then just generate an <A> element with that URL as the href attribute. No conversion is going on there.
joseph cooper
Ranch Hand

Joined: Nov 08, 2005
Posts: 44
I am fairly new to xslt/html and I do not have all the lingo down. Yes I have the text of the url and I am wanting the url to appear as a hyperlink on the web page. I can now get the link to show up on the web page, but when I click on the link I get a "page cannot be displayed" error. I also tried to have the hyperlink open the site on a new page. I am receiving an error "Cannot find 'file:///CEV/IBM/wid6.0.1/JavaProject/ResultFormat/log/link'. Make sure the path or Internet addres is correct." I do not know where the path is coming from but the internet address is correct. From the IE I can open the page myself.

Is there something else that needs to be added?

Thanks for the help in advance

I added this

code:

Element link = xmlDoc.createElement("link");
link.appendChild(xmlDoc.createTextNode(memberOfClientList.link));
client.appendChild(link);

xslt:

<TD width="93%">
<font color="blue">
<!--<a href="link" target="_blank">-->
<a href="link">
<xsl:value-of select="link"/>
</a>
</font>
</TD>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

<a href="link">
Well, this is valid HTML and the URL it refers to is "link". It's interpreted as being relative to the base URL of your HTML document which I suppose must be something in the CEV/IBM/wid6.0.1/JavaProject/ResultFormat/log folder.

But you didn't want the URL to be the string constant "link" in your transformation, I don't think. You wanted it to be the value of a <link> element in your XML source document. To do that you use an Attribute Value Template:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL conversion
 
Similar Threads
help with the code for check boxes
When Validation Error I Lose My Bean Value-Struts 2
font size
reg html tables
HTML does not print properly - table width exceeding 100%?