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 August 7th, 2004, 02:53 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to miguel
Default assigning a css style sheet from an element

Hi everybody, im trying to assing a style sheet whose name i have in a xml element like this:

<style>"http://projecto/css/edit5.css"</style>
 and i get this error on the xsl editor "NOT WELL FORMED :&EXPECTED"

   when i try to pass it to a html <link> tag like this:


 <xsl:template match="style">

 <link rel = "stylesheet" type="text/css"
        href= "<xsl:value-of select="."/>"
 < q/link>

  </xsl:template>


could anyone help me on this?:)
 
Old August 7th, 2004, 03:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe your doublequotes confuse the parser?! Not sure whether you can substitute with single quotes!
 
Old August 7th, 2004, 03:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try have another look at your tags. You have a doublequote outside one tag and where does the < q/link> belong? Not that I'm an expert, but it looks odd!
 
Old August 7th, 2004, 03:53 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to miguel
Default

tnx birger but that was my mistake but even if i correct it the problem persists

<xsl:template match="style">

 <link rel = "stylesheet" type="text/css" href= "<xsl:value-of select="."/>" >
</link>
</xsl:template>

 
Old August 7th, 2004, 03:56 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to miguel
Default

oh , and the single quotes dont work neither

 
Old August 7th, 2004, 04:14 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to miguel
Default

ok now i found the problem , indeed the double quotes on the xml were part of the problem ( birgie sorry) so i removed them and changed the xml to this, which works fine:


 <xsl:template match="style">

 <link rel = "stylesheet" type="text/css" href= "{.}" >
 </link>

 </xsl:template>




 
Old August 8th, 2004, 02:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great - I'll use it myself!
 
Old August 8th, 2004, 01:21 PM
Authorized User
 
Join Date: Oct 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

FYI -- using "{.}" indeed works; this is called an "attribute value template" and will work fine as long as you are using a "literal result element" to output the parent element (which is what you are doing with the "link" element) rather than using xsl:copy or xsl:element for that purpose, and as long as the value of the attribute does not require complex logic.

The following solution uses xsl:attribute which allows more flexibility if you need it:

<xsl:template match="style">

 <link rel = "stylesheet" type="text/css">
  <xsl:attribute name="href">
    <xsl:value-of select="."/>
  </xsl:attribute>
 </link>

 </xsl:template>

...sam






Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel vba, assigning a Name to a sheet stepdev Excel VBA 3 October 31st, 2015 07:32 AM
Assigning node value to a href element!!!!!!!!! rakesh XSLT 4 July 25th, 2008 03:17 PM
cascading style sheet problem nikotromus ASP.NET 2.0 Professional 0 March 24th, 2006 07:49 PM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
Setting the Style Sheet class jacob ASP.NET 1.0 and 1.1 Basics 4 August 20th, 2003 01:53 AM





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