You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Dudka Tetyana <te...@epfl.ch> on 2004/10/31 18:51:57 UTC
How to associate css file from JAVA?
Hello!
I have mystyle.css file.
rect {
fill: red;
stroke: blue;
stroke-width: 3
}
I want to associate all style properties for SVG element using Cascading
Style Sheets from the external
CSS file. And I want to connect this css file from java application. And I
don't know how to do this
exactly from java file and then instead of writing
rect.setAttributeNS(null, "style", "fill: red; stroke-width: 3");
I want just say what style to use.
How can I do this?
Re: How to associate css file from JAVA?
Posted by Måns Rullgård <mr...@inprovide.com>.
Thomas DeWeese <Th...@Kodak.com> writes:
> Dudka Tetyana wrote:
>> Hello!
>> I have mystyle.css file.
>> rect {
>> fill: red;
>> stroke: blue;
>> stroke-width: 3
>> }
>> I want to associate all style properties for SVG element using
>> Cascading Style Sheets from the external
>> CSS file. And I want to connect this css file from java
>> application. And I don't know how to do this
>> exactly from java file and then instead of writing
>> rect.setAttributeNS(null, "style", "fill: red; stroke-width: 3");
>> I want just say what style to use.
>> How can I do this?
>>
> The easiest way would be to add an 'svg:style' element
> to the document and have that reference mystyle.css with it's
> xlink:href attribute.
You could also add an XML processing instruction, like this:
String data =
"href=\"stylesheet.css\" type=\"text/css\"";
ProcessingInstruction pi =
doc.createProcessingInstruction("xml-stylesheet", data);
doc.insertBefore(ssp, doc.getDocumentElement());
--
Måns Rullgård
mru@inprovide.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: How to associate css file from JAVA?
Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Dudka,
The easiest way would be to add an 'svg:style' element
to the document and have that reference mystyle.css with it's
xlink:href attribute.
There isn't a really clean way to do this without adding
the node (you could potentially make it the useragent stylesheet
or something).
Dudka Tetyana wrote:
>
>
> Hello!
>
> I have mystyle.css file.
>
> rect {
>
> fill: red;
>
> stroke: blue;
>
> stroke-width: 3
>
> }
>
> I want to associate all style properties for SVG element using Cascading
> Style Sheets from the external
>
> CSS file. And I want to connect this css file from java application. And
> I don’t know how to do this
>
> exactly from java file and then instead of writing
>
> rect.setAttributeNS(null, "style", "fill: red; stroke-width: 3");
>
> I want just say what style to use.
>
> How can I do this?
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org