Reputation: 189856
I have an XSL stylesheet that I need to use because it has stuff that's really hard to recreate. And I can't edit it, either. So I'm using <xsl:import>
to import the XSL stylesheet, and then I'm overriding a few templates. But one has me stumped:
<xsl:template match="mscript">
<html>
<!-- head -->
<head>
<!-- ... other stuff not important ... -->
<xsl:call-template name="stylesheet"/>
</head>
<body>
<!-- ... more stuff ... -->
and the stylesheet
template, which sticks in a <style type='text/css'>...</style>
tag and is mostly useful, starts with this boneheaded nonsense:
<xsl:template name="stylesheet">
<style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,
small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,
form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td
{margin:0;padding:0;border:0;outline:0;font-size:100%;
vertical-align:baseline;background:transparent}
Argh! Makes me nauseous.
I can override the stylesheet completely in my root XSL file, but what I'd really like to do is just nullify this one CSS rule.
Is there a way to do that? Here's kind of what I'd like to do:
<xsl:template name="stylesheet">
<xsl:call-template name="imported_stylesheet" />
<style type="text/css">
<!-- nullify the boneheaded nonsense -->
h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,
small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,
form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td
{margin: default; padding:default;border:default;outline:default;font-size:default;
vertical-align:default;background:default}
</style>
</xsl:template>
but default
isn't a CSS feature, and I don't know how to call the imported stylesheet, since when I override the stylesheet
template, its previous value disappears.
Upvotes: 1
Views: 534
Reputation: 70648
I believe CSS does not currently have a way to reset a style to the browser default value (See Reset CSS display property to default value)
I can think of one very 'crude' way of doing what you are trying to achieve. Assuming the stylesheet template does just return a single style element, you could wrap the call:template command in a variable, and then just strip out the first rule. Something like this
<xsl:variable name="style">
<xsl:call-template name="stylesheet"/>
</xsl:variable>
<style type="text/css">
<xsl:value-of select="substring-after($style, '}')" />
</style>
This would just out the CSS rules after the first one.
Are you sure you cannot edit the imported stylesheet though? Can't you hunt down the person who wrote it, and ask them to change it to allow a parameter which specifies whether you want the first rule or not? Or maybe you can just take a copy of the imported stylesheet, and change it for you own purpose....
Upvotes: 2