Solved

How to write target="_blank" in xsl?

Posted on 2009-04-14
6
1,021 Views
Last Modified: 2013-11-18
Hi

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 http://www.johnvey.com/features/deliciousdirector/xslt-filter-sort.html

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>
							</xsl:element>
							<xsl:attribute name="target">_blank</xsl:attribute>
						</xsl:element>
						<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>
							<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
									</xsl:attribute>
								</xsl:element>
							</xsl:element>
						</img>
					</a>
				</xsl:when>

Open in new window

0
Comment
Question by:techques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 60

Accepted Solution

by:
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">
here
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
0
 

Author Comment

by:techques
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
<name>dbtable</name>
	<proplist>
		<rowselector>0</rowselector>
		<id>t.id</id>				   <ActionProc>'../images/edit.gif'</ActionProc>
		<ActionProc_Alt>'Process'</ActionProc_Alt>
		<ActionProc_link>'Process.aspx?id=' + Convert(char(10),t.id)</ActionProc_link>
</proplist>
 
//Display on aspx
 
<column>
		<visible>1</visible>
		<sortable>0</sortable>
		<header>
			<title>Process</title>
			<style>
				<width>2%</width>
				<class>list_title</class>
			</style>
		</header>
		<data>
			<prop>ActionProc</prop>
			<type>imagelink</type>
			<imagelink>
				<image>
					<style>
						<alt>Process</alt>
					</style>
				</image>
			</imagelink>
		</data>
		<cell>
			<styletype>fixed</styletype>
			<fixed>
				<style>
					<nowrap>1</nowrap>
					<align>center</align>
				</style>
			</fixed>
		</cell>		
	</column>

Open in new window

0
 
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
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:techques
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?

<div 
	style="behavior:url('../listview2.htc');"
	ID="idDefView1"
	ControlBaseDirectory="../ListView"
	DataProcessorURL="../ListView/DataProcessor.aspx"
	ViewTemplateXSL="../ListView/listview2.xml"
	ViewDescriptor="/desc_process_list.xml"
	ViewDataMap="/map_process_list.xml"
	ItemCount="0"
	RowsPerPage="5"
	RowBehavior=""
	RowHref="#"
	RowHrefTarget="_self"
	Filter=""
	QueryHolder="hid_ctl01$idDefView1"
	InvisibleCols=""
	Pager_Visible="True"
	Pager_VerticalAlign="bottom"
	Pager_HorizontalAlign="right"
	Pager_LinkStyle="page"
	Pager_ButtonStyle="button"
	Pager_FormStyle="form"
/>

Open in new window

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

Author Comment

by:techques
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.








xsl.JPG
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Transform XML to Excel using XSL 1 42
Eliminate additional border 1 29
Append data to an XML file 3 34
ASP AND XML 3 42
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

752 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