How to write target="_blank" in xsl?

Posted on 2009-04-14
Last Modified: 2013-11-18

I have a listview which has an imagelink. It can direct to another page when I click the image. Now, I want the page to be shown in a popup window.

I read

and added target="_blank" to <a>

However, it cannot trigger the popup
<xsl:when test="type[. $eq$ 'imagelink']">
					<a target="_blank">
						<xsl:apply-templates select="imagelink/style" />
						<xsl:element name="xsl:attribute">
							<xsl:attribute name="name">href</xsl:attribute>
							<xsl:element name="xsl:value-of">
								<xsl:attribute name="select">
									../<xsl:value-of select="prop" />_link
							<xsl:attribute name="target">_blank</xsl:attribute>
						<img border="0">
							<xsl:apply-templates select="imagelink/image/style" />
							<xsl:element name="xsl:attribute">
								<xsl:attribute name="name">src</xsl:attribute>
								<xsl:element name="xsl:value-of" />
							<xsl:element name="xsl:attribute">
								<xsl:attribute name="name">Alt</xsl:attribute>
								<xsl:element name="xsl:value-of">
									<xsl:attribute name="select">
										../<xsl:value-of select="data/prop" />_Alt

Open in new window

Question by:techques
  • 3
  • 3
LVL 60

Accepted Solution

Geert Bormans earned 50 total points
ID: 24145225
that is because the other attributes are not on the <a> element but on an <xsl:attribute> element,
which is very weird, I don't undersatnd why you have a <xsl:attribute> in your output.
That happens here:
<xsl:element name="xsl:attribute">
I assume you want
<xsl:element name="a">
but then I don't get what the <a target="_blank"> is doing at the start of your template

I recommend that you use your stylesheet do do a static transform in an IDE
and look at the result.
It will then become very clear why it doesn't work.

Or send in the full XML and XSLT

Author Comment

ID: 24145281
As it needs to map the data from a table in DB in another xml and display in another xml file.

How should I change <xsl:element name="xsl:attribute"> to enable the target="_blank"?

//map to DB
		<id></id>				   <ActionProc>'../images/edit.gif'</ActionProc>
		<ActionProc_link>'Process.aspx?id=' + Convert(char(10),</ActionProc_link>
//Display on aspx

Open in new window

LVL 60

Expert Comment

by:Geert Bormans
ID: 24145352
Are you generating an XSLT, you then use for generating the html?
I would assume you need to pipe two XSLT instead
So, I am lost here

<xsl:element> creates an element in the result tree
so creating an <xsl:attribute> element is only usefull when you need to construct an XSLT
I hardly ever had to go down that route, I assume you don't

I assume you just want to output an <a> element
<xsl:element name="a"> will do then
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


Author Comment

ID: 24145579
Are you generating an XSLT, you then use for generating the html?
Yes, it uses ViewTemplateXSL to generate it

May I ask why I added <xsl:attribute name="target">_blank</xsl:attribute> still not work?


Open in new window

LVL 60

Expert Comment

by:Geert Bormans
ID: 24145596
I don't understand the <div> thing you just added
I think you misunderstood my question about generating XSLT
The question really is: do you use XSLT to make a different XSLT?

Author Comment

ID: 24145716
do you use XSLT to make a different XSLT? I don't think so. Let me explain:

1) In aspx, I import a module <%@ Register TagPrefix="OA" Namespace="OA.WebControl.ListView" Assembly = "OA.WebControl.ListView" %>

and then write the following code.

<OA:LISTVIEW id=idDefView runat="server" ControlBaseDirectory="../ListView" ViewDescriptor="desc_processmemo_list.xml" ViewDataMap="map_processmemo_list.xml" RowHref="#" RowHrefTarget="_self" RowsPerPage="5" Filter=""></OA:LISTVIEW>

Then the select result from DB will display.

The <div> code was that I view the source from browser which should be the html. It is irrelevant to the code.

As this part was not written by me. I just know how to use the ListView module to display DB data on aspx page.

The image shows that there is a Process in the last column which is an image. I just want that when I click it, it pop up a new window to display the aspx page.

I just need the pop up function.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trouble parsing soap xml result 3 57
Convert XML to excel12book 5 32
XML response optional elements 12 50
Xsl-fo show PDF when no results are returned 2 20
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question