Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL conversion

 
joseph cooper
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic