Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2013, 05:11 AM
Registered User
 
Join Date: Feb 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default <a target="_blank"> not working

I have a dynamic web page with an <a> where the href varies with the contents. I would like the <a> to open in a new tab instead of a new IE. I use <a href="......." target="_blank"/> to achieve this but got different results. If I use jsp to generate the html, the <a> open a new tab as I expected. But if I use servlet to dynamically generate xml and use xsl to transform it, the target="_blank" opens a new IE instead of a new tab. But when I save the xml and xsl into local folder and open them with IE, it opens new tab. Is there a better way to code the <a> so that it will open new tab all the times?
 
Old February 26th, 2013, 06:05 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The output from your jsp and your servlet should be identical - i.e. if you do "View Source" in the browser they should be the same.

If they are not the same then fix that. If they are the same then it something the browser is doing - possibly to do with the relationship between the current page domain or url and the new page url.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 27th, 2013, 02:37 AM
Registered User
 
Join Date: Feb 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sam, thanks for the reply. Looking back to my post it seems quite confusing. Allow me to rephase it:

(1). using jsp to generate html, target="_blank" in the resulting html leads to new tab, as expected.
(2). instead of jsp->html, using servlet to write xml to IE with xslt, target="_blank" in the xsl leads to new IE opened, not new tab.
(3). In 2, if I view the source in IE and save the xml together with the xsl, open the xml directly with IE, target="_blank" leads to new tab, as expected.

I don't know if there is any method to make (2) above also open new tab.

Last edited by senderj; February 27th, 2013 at 02:41 AM.. Reason: clarify
 
Old February 27th, 2013, 04:08 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Without seeing the XSLT and XML I can't be sure, but this sounds like an issue with IE, and not with the XSLT. Not sure why your servlet served XML should behave differently when loaded locally, as that doesn't make much sense.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 27th, 2013, 06:18 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Let's start with a basic fact: the way IE renders an HTML document does not depend on what server-side techology you used to produce the document. So if two documents are rendered differently, they must be different. Or at the very least, they must be served with different HTTP headers. Start by looking for the differences (as Sam advised).

One possibility to explore is that the two documents have different base URIs which means they are referring to different CSS stylesheets.

One thing I notice is that you talk of your XSLT producing XML output. Why are you producing XML rather than HTML output? Is this anything to do with the problem?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old February 27th, 2013, 08:49 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I assumed that the servlet generated XML with an embedded XSLT (or stylesheet reference) for rendering in IE. If that's not the case then I don't know what is happening, and it needs explaining better.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 28th, 2013, 12:28 AM
Registered User
 
Join Date: Feb 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default <meta> in xsl

I have to apologie as I found that the problem has nothing to do with xslt, but depends on whether the page is in a frame or not. Sorry for wasting your time and appreciate your advises.

I have another question when trying to resolve my problem. Is there a way to control the <meta> generated from xslt, in particular the "charset" attribute? I tried to add <meta> into the xsl, but it generates two <meta> in the resulting html, one from xslt and one from mine.
 
Old February 28th, 2013, 12:28 AM
Registered User
 
Join Date: Feb 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default <meta> in xsl

I have to apologie as I found that the problem has nothing to do with xslt, but depends on whether the page is in a frame or not. Sorry for wasting your time and appreciate your advises.

I have another question when trying to resolve my problem. Is there a way to control the <meta> generated from xslt, in particular the "charset" attribute? I tried to add <meta> into the xsl, but it generates two <meta> in the resulting html, one from xslt and one from mine.
 
Old February 28th, 2013, 04:52 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Best to start a new thread when there is a new question.

You can control the charset in the generated meta element using the encoding property of xsl:output.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting "margin-top" Attribute of <fo:region-body> ritagr XSLT 0 January 18th, 2013 05:37 PM
"type" attribute in <script> tag Latinsteps BOOK: Beginning JavaScript 4th Edition 2 September 6th, 2011 01:29 AM
<%@ MasterType virtualPath="~/EAD_EditGrid.master"%> not recognised MattHoff BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 1 July 27th, 2010 10:21 AM
<deployment retail="true"> clarification jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 1st, 2009 02:48 PM
<authentication mode="Forms"/> msman88 ASP.NET 3.5 Professionals 10 August 30th, 2009 08:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.