Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open new window from XSLT 1

Status
Not open for further replies.

abs2003

MIS
Aug 31, 2004
80
US
Hi everybody,

Remember in HTML you can put tag
Code:
<a href="[URL unfurl="true"]www.somthing.com"[/URL] target="_blank">

How can I do the same on XSLT file?

Thank you,

ab
 
You can't. This doesn't make sense. XSL simply describes rules for transforming a source XML tree into a result tree.

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
You mean like this...?

XML: (test.xml)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<Test>
  <Page>
    <Name>Test Page</Name>
    [b]<Link>Test.html</Link>[/b]
  </Page>
</Test>
XSLT: (test.xsl)
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
    <html>
      <body>
        <center>
          <table border="1" width="100%">
            <tr align="center">
              <th>Links</th>
            </tr>
            <xsl:for-each select="//Page">
              <tr align="center">
                <td>[b]<a href="{Link}" target="_blank"><xsl:value-of select="Name"/></a>[/b]</td>
              </tr>
            </xsl:for-each>
          </table>
        </center>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Should work like this...
HTML: (test.html)
Code:
<html>
<body>
<h1>New Page</h1>
[b]<a href="test.xml" target="_blank">Go Back</a>[/b]
</body>
</html>


Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
CubeE101,

My code
Code:
<xsl:if test="string-length(Website)">
	<b>WebSite:&#160;</b>
	<a>
		<xsl:attribute  name="href">
			<xsl:value-of select="Website"/> 
		</xsl:attribute>
		<xsl:value-of select="Website"/>
	</a><BR/>
</xsl:if>

Where do I insert
Code:
target="_blank"
?

By the way, good code you posted above. you certainly got a star from me.

Thanks,
 
like this:
Code:
<xsl:if test="string-length(Website)">
    <b>WebSite:&#160;</b>
    <a href="{Website}" target="_blank">
        <xsl:value-of select="Website"/>
    </a><BR/>
</xsl:if>

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
This is what I did to solve the problem.
Code:
<xsl:if test="string-length(Website)">
	<b>WebSite:&#160;</b>
	<a target="_blank">
		<xsl:attribute  name="href">
			<xsl:value-of select="Website"/> 
		</xsl:attribute>
		<xsl:value-of select="Website"/>
	</a><BR/>
</xsl:if>

Thank you all for your help.
 
Is there a reason why you are using:
Code:
        <xsl:attribute  name="href">
            <xsl:value-of select="Website"/> 
        </xsl:attribute>

instead of:
Code:
href="{Website}"

?

I never could get the attribute tag to work right...

(I use IE for browsing)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
CubeE101,
I had to do the way I did because my link (Website) is dynamic data from SQL table. I can't hard code in as
Code:
href="www.mysite.com"

Good luck,
 
Did you try the code I posted?

the brackets replace the <xsl:attribute> & <xsl:value-of> tags...
Code:
<A>
  <xsl:attribute name="href">
    <xsl:value-of select="[b]Website[/b]"/> 
  </xsl:attribute>
  <xsl:value-of select="[b]Name[/b]"/> 
</A>

Is the same as:
Code:
<A href="{[b]Website[/b]}">
  <xsl:value-of select="[b]Name[/b]"/> 
</A>

Give It a try... ;-)

Works for src, and any other attribute as well...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top