Solved

xsl:attribute-set name <STYLE>

Posted on 2014-11-14
4
220 Views
Last Modified: 2014-11-20
I want to know how I can keep from repeating the styling code for a <td> in an xsl stylesheet.

Current code:
								     <td Style="
									font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
									font-weight: bold;
									font-size: 10pt;
									font-style: normal;
									font-variant: small caps;
									text-align: center;
									text-decoration: none;
									color:#ffffff;
									background-color: #000099;
									padding-top: 5px;
									padding-bottom: 5px;
									padding-left; 2px;
									padding-right: 2px">View</td>

Open in new window

The above works but must be repeated for each element in the row. I think it can be done in one line using xsl:use-attribute-sets . Below is my first attempt:
[<td  colspan="2" xsl:use-attribute-sets="rowheader">Market Value</td>

Open in new window

based on this code at the top of the stylesheet
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:auto="http://www.w3.org/TR/WD-xsl">
    <xsl:attribute-set name ="rowheader">
        <xsl:attribute name ="font-family">Verdana, Geneva, Arial, Helvetica, sans-serif</xsl:attribute>
        <xsl:attribute name ="font-weight"> bold</xsl:attribute>
        <xsl:attribute name ="font-size">10pt</xsl:attribute>
        <xsl:attribute name ="font-variant">small caps</xsl:attribute>
        <xsl:attribute name ="text-align">center</xsl:attribute>
        <xsl:attribute name ="color">#ffffff</xsl:attribute>
        <xsl:attribute name ="background-color">#000099</xsl:attribute>
        <xsl:attribute name ="padding-top">5px</xsl:attribute>
        <xsl:attribute name ="padding-bottom">5px</xsl:attribute>
        <xsl:attribute name ="padding-left">2px</xsl:attribute>
        <xsl:attribute name ="padding-right">2px</xsl:attribute>
    </xsl:attribute-set>

Open in new window

I'm working with someone else's code and their call-template doesn't find the stylesheet so I'm trying this approach.

I've searched stackoverflow and others but they don't have complete examples of the basics.

It's very early in my self-education on xsl.  I'm hoping all I've done is mess up some syntax.
0
Comment
Question by:bob_mechler
[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
  • 2
  • 2
4 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 40442628
<tr xsl:use-attribute-sets="rowheader">
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 40442640
strange, I see you have that already, that should work actually

note you can regroup and reuse

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:auto="http://www.w3.org/TR/WD-xsl">
    <xsl:attribute-set name ="rowheader">
        <xsl:attribute name ="background-color">#000099</xsl:attribute>
        <xsl:attribute name ="padding-top">5px</xsl:attribute>
        <xsl:attribute name ="padding-bottom">5px</xsl:attribute>
        <xsl:attribute name ="padding-left">2px</xsl:attribute>
        <xsl:attribute name ="padding-right">2px</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:attribute-set name ="general">
        <xsl:attribute name ="font-family">Verdana, Geneva, Arial, Helvetica, sans-serif</xsl:attribute>
        <xsl:attribute name ="font-weight"> bold</xsl:attribute>
        <xsl:attribute name ="font-size">10pt</xsl:attribute>
        <xsl:attribute name ="font-variant">small caps</xsl:attribute>
        <xsl:attribute name ="text-align">center</xsl:attribute>
        <xsl:attribute name ="color">#ffffff</xsl:attribute>
    </xsl:attribute-set>
    
    <xsl:template match="/">
        <td  colspan="2" xsl:use-attribute-sets="rowheader general">Market Value</td>
        <td  xsl:use-attribute-sets="general">Simple P</td>
    </xsl:template>
    
    
    
</xsl:stylesheet>

Open in new window


And yes, that is the best way to go about matters like this
0
 

Author Comment

by:bob_mechler
ID: 40455173
I gave up trying to make asp.net 1.1 work. I also discovered that the CSS was not working because of the directory it was in. ASP.NET 1.1 didn't have an issue with it being in a sub folder. When I placed the STYLE.CSS in the root folder of the website, everything started working. I had also loaded the project into Visual Studio 2010 with everything set to 2.0 Classic application pool. I even made sure that on II7 no other application pool was even started besides the 2.0 Classic. Visual Studio 2010 did not convert on previous tries when other application pools were available. The web site now works.

Please, no need for furth responses. I did however learn a great deal about css elements in xsl so I'll give credit to the person who helped the most.
0
 

Author Closing Comment

by:bob_mechler
ID: 40455180
I received useful insight although I solved the issue by moving in a different direction. Thanks!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

628 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