Thanks for that Thomas. For anyone having a similar problem, this solution works!
Thanks again, Dylan. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 14 December 2005 11:06 To: [email protected] Subject: RE: Using CSS in Batik Hi Dylan, "Dylan Browne" <[EMAIL PROTECTED]> wrote on 12/14/2005 02:09:28 AM: > Sorry, I wasn't specific enough in my question. I am familiar with using CSS > in SVG, but I have recently begun using the Apache Batik SVG java libraries, > using the SVG DOM, to create SVG dynamically from java. > > Currently I am using code like this to style my Elements: > > text.setAttributeNS(null, "style", > "fill:green;font-family:sans-serif;font-size:18pt;text-anchor:middle"); > > And what I would like to be able to do instead is import my stylesheet into > the SVG DOC that I generate through Java. Just create an 'xml-stylesheet' processing instruction and insert it before the root element in your dynamic document: ProcessingInstruction pi = doc.createProcessingInstruction ("xml-stylesheet", "type=\"text/css\" href=\"foo.css\""); doc.insertBefore(pi, doc.getRootElement()); > I can see there is a style sheet class, but no examples on how to use it. > That's really what I was after. I don't think there is a standard way to construct a stylesheet 'in memory' and attach it to a document. To be honest I'm not an expert in the CSS DOM. If you wanted to hack against Batik internals you might be able to pull it off but it would be fairly ugly. The main 'CSS' class in Batik is org.apache.batik.css.engine.CSSEngine but it seems to always get it's list of StyleSheets from the document. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
