Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Embedding a CSS style sheet within a generated SVG file (http://www.velocityreviews.com/forums/t165757-embedding-a-css-style-sheet-within-a-generated-svg-file.html)

FC 09-30-2003 10:25 PM

Embedding a CSS style sheet within a generated SVG file
 
Hello folks,
I was wondering if there any other method of achieving the following:

I have a XSL transformation outputting a SVG document.
For reasons too long to explain here, I must embed a CSS style sheet inside
a <style> element in the SVG output document using a CDATA block.
The CSS stylesheet is not an xml document, therefore I cannot open it using
the document function (I suppose, I didn't even try frankly).
In order to work around the problem, I created a "parallel" xml version of
the CSS stylesheet, just embedding everything within a <css> element, plus
the usual xml header.
In this fashion I can open it with document and extract the text node
belonging to <css> and copy it to the output document.

This rather cumbersome method forces me to re-create the fake css every time
I modify the real stylesheet, so I was just asking myself if it is a
by-product of too many late hours or just an honest solution.

Here is the code:

<xsl:if test="$embed=1">

<style type="text/css">

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<xsl:value-of select="document(concat($css,'.xml'))/css/text()"/>

<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>

</style>

</xsl:if>


Thanks for your advice,
Flavio



Thomas Meinike 10-01-2003 10:57 AM

Re: Embedding a CSS style sheet within a generated SVG file
 
FC wrote:

>In order to work around the problem, I created a "parallel" xml version of
>the CSS stylesheet, just embedding everything within a <css> element, plus
>the usual xml header.
>In this fashion I can open it with document and extract the text node
>belonging to <css> and copy it to the output document.


You can create a processing instruction for including the external
stylesheet:

<xsl:processing-instruction name="xml-stylesheet">
href="<xsl:value-of select="..."/>" type="text/css"
</xsl:processing-instruction>

cu, Thomas
--
SVG - Learning By Coding
<http://www.datenverdrahten.de/svglbc/>

FC 10-01-2003 12:31 PM

Re: Embedding a CSS style sheet within a generated SVG file
 

"Thomas Meinike" <news@handmadecode.de> wrote in message
news:3f7ab2cd.9472809@news.cis.dfn.de...
> FC wrote:
>
> >In order to work around the problem, I created a "parallel" xml version

of
> >the CSS stylesheet, just embedding everything within a <css> element,

plus
> >the usual xml header.
> >In this fashion I can open it with document and extract the text node
> >belonging to <css> and copy it to the output document.

>
> You can create a processing instruction for including the external
> stylesheet:
>
> <xsl:processing-instruction name="xml-stylesheet">
> href="<xsl:value-of select="..."/>" type="text/css"
> </xsl:processing-instruction>
>
> cu, Thomas
> --
> SVG - Learning By Coding
> <http://www.datenverdrahten.de/svglbc/>



Well, thanks, I know I can do it, but the story goes that I can't use that
method because the server where these pages are located does not send the
correct MIME type and the page is displayed as plain text.
I cannot change the situation as I am not the webmaster and these guys want
to get paid for the "service".
If you try to work around the problem by embedding the svg page inside
<object> (because it allows to specify the MIME type in the type attribute)
then you'll find out soon that it doesn't work properly (IE 5.5, IE 6) when
you use a reference to a CSS stylesheet, but it does work when you include
the CSS as a CDATA block.

Indeed my XSLT program takes a parameter specifying if the CSS must be
linked or included, so when it is linked, it works exactly as you suggested.

Bye,
Flavio



Thomas Meinike 10-01-2003 12:39 PM

Re: Embedding a CSS style sheet within a generated SVG file
 
FC wrote:

>If you try to work around the problem by embedding the svg page inside
><object> (because it allows to specify the MIME type in the type attribute)
>then you'll find out soon that it doesn't work properly (IE 5.5, IE 6) when
>you use a reference to a CSS stylesheet, but it does work when you include
>the CSS as a CDATA block.


Try to use an absolute URI refererence http://.../your.css

My XSLT/SVG application
<http://www.et.fh-merseburg.de/person/meinike/mspecsvg/> runs with
this method using xsl:processing-instruction.

cu, Thomas
--
SVG - Learning By Coding
<http://www.datenverdrahten.de/svglbc/>

FC 10-01-2003 12:55 PM

Re: Embedding a CSS style sheet within a generated SVG file
 

"Thomas Meinike" <news@handmadecode.de> wrote in message
news:3f7acaaa.15582660@news.cis.dfn.de...
> FC wrote:
>
> >If you try to work around the problem by embedding the svg page inside
> ><object> (because it allows to specify the MIME type in the type

attribute)
> >then you'll find out soon that it doesn't work properly (IE 5.5, IE 6)

when
> >you use a reference to a CSS stylesheet, but it does work when you

include
> >the CSS as a CDATA block.

>
> Try to use an absolute URI refererence http://.../your.css
>
> My XSLT/SVG application
> <http://www.et.fh-merseburg.de/person/meinike/mspecsvg/> runs with
> this method using xsl:processing-instruction.
>
> cu, Thomas
> --


Ok, thank you again, perhaps I didn't stress enough the subject of my
request.
I am interested in knowing how to include a non-xml document into an xml
document by means of xslt.
So the origin of this request can be neglected for a while.

I am quite satisfied with the method I found, it works when I need to
perform tests locally and it works remotely, I am not bound to an active
Internet connection just to retrieve a stylesheet.
Moreover, generally speaking, the relative URI to the stylesheet does work
correctly with IFRAME, the problem is just with "my" server who doesn't
handle the correct MIME and I haven't got the privileges to add it.

Cheers,
Flavio




All times are GMT. The time now is 01:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.