[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problems transforming a <A HREF> link using XSL

Subject: RE: Problems transforming a <A HREF> link using XSL
From: "Allison Bloodworth" <abloodworth@xxxxxxxxxxxx>
Date: Fri, 18 Nov 2005 09:17:02 -0800
xsl a href
Thanks very much for responding, Michael. However, xsl:copy-of gives me
this:

	Gametracker: <gametracker>
         <a
href="JavaScript:window.open('http://livestats.calbears.collegesports.com/li
vestats/data/m-baskbl/353109/','mbaskblGameTracker','toolbar=no,resizable=no
,scrollbars=no,width=780,height=540'); void('');">Gametracker</a>
      </gametracker>

And I want this:

	Gametracker: 
         <a
href="JavaScript:window.open('http://livestats.calbears.collegesports.com/li
vestats/data/m-baskbl/353109/','mbaskblGameTracker','toolbar=no,resizable=no
,scrollbars=no,width=780,height=540'); void('');">Gametracker</a>
      
(e.g. I don't want the <gametracker> tags around my link)

I was able to do what you suggested with copy of if I target the <a> tag.
However, I can't assume that the Gametracker tag will always include just
the <a> tag. 

	<xsl:template match="gametracker">
		<xsl:if test="normalize-space(.)">
	Gametracker: <xsl:copy-of select="a"/>
		</xsl:if>
	</xsl:template>

If you want to copy HTML content inside an XML tag and don't know exactly
what it is, is this not possible?

Also, if there is a better way to use an XSL to do datatype testing on the
contents of a node (hopefully using XPath 1.0, since I can't use XML Spy on
a stylesheet with "castable"...thank goodness for Saxonica!), I'd love to
hear of it. Right now this is what I'm doing:

		<xsl:if test="string(.) castable as xs:time">
			<StartTime>
				<xsl:value-of select="."/>

			</StartTime>			
		</xsl:if>

Thanks again!
Allison
-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Friday, November 18, 2005 1:09 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Problems transforming a <A HREF> link using XSL

You want <xsl:copy-of> rather than <xsl:value-of>.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Allison Bloodworth [mailto:abloodworth@xxxxxxxxxxxx] 
> Sent: 18 November 2005 02:04
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Problems transforming a <A HREF> link using XSL
> 
> Hi, 
> 
> I am trying to transform an XML document, which includes some HTML <a
> href=.> links, into another XML document. However, when I do the
> transformation, the <a href=..>Name of link</a> info is lost 
> and all I see
> is the name of the link. I've tried using output methods of 
> "xml" "html" and
> "text" to no avail. Does anyone know how to fix this problem?
> 
> <?xml-stylesheet type="text/xsl" href="Sports.xsl"?>
> <feed>
> <update_stamp>11/10/2005 08:14:47</update_stamp>
>    <event>
>       <id>472691</id>
>       <date>12/03/2005</date>
>       <time>1:00 PM</time>
>       <sport>w-baskbl</sport>
>       <sport_name>W Basketball</sport_name>
>       <opponent><![CDATA[UNLV vs. Albany (CC Times 
> Classic)]]></opponent>
>       <location><![CDATA[Berkeley]]></location>
>       <tv></tv>
>       <home_visitor>H</home_visitor>
>       <outcome><![CDATA[]]></outcome>
>       <recap></recap>
>       <stats></stats>
>       <notes></notes>
>       <quotes></quotes>
>       <gallery></gallery>
>       <gametracker><a
> href="JavaScript:window.open('http://livestats.calbears.colleg
> esports.com/li
> vestats/data/w-baskbl/354046/','wbaskblGameTracker','toolbar=n
o,resizable=no
> ,scrollbars=no,width=780,height=540');
> void('');">Gametracker</a></gametracker>
>    </event>
> </feed>
> 
> Top of XSL stylesheet:
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:dt="http://xsltsl.org/date-time">
> <xsl:import href="http://xsltsl.sourceforge.net/modules/stdlib.xsl"/>
> <xsl:output method="xml" indent="yes"/>
> 
> Pertinent portion of stylesheet (I test to see if the element 
> exists before
> I print it): 
> 
>             <xsl:template match="gametracker">
>                         <xsl:if test="normalize-space(.)">
>             Gametracker: <xsl:value-of select="."/>
>                         </xsl:if>
>             </xsl:template>
> 
> I want this in the resultant XML file:
> <Description>
>             Gametracker: <a
> href="JavaScript:window.open('http://livestats.calbears.colleg
> esports.com/li
> vestats/data/w-baskbl/354046/','wbaskblGameTracker','toolbar=n
o,resizable=no
> ,scrollbars=no,width=780,height=540'); void('');">Gametracker</a>
> </Description>
> 
> But I get this:
> 
> <Description>
>             Gametracker: Gametracker
> </Description>
> 
> Thanks very much for any help you can give me!
> 
> Allison Bloodworth
> Principal Administrative Analyst
> e-Berkeley Program Office
> University of California, Berkeley
> (415) 377-8243
> abloodworth@xxxxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.