I generate a String like this... 

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'svg10.dtd'>
<svg width="210mm" xmlns:xlink="http://www.w3.org/1999/xlink"; height="
297mm" xmlns="http://www.w3.org/2000/svg"; version="1.0">
<g>

...

<g>
</svg>

//////////////////////////////////////////////

then I have method, which creates a SVGDocument from the upper String...

public SVGDocument loadSVGDocument(String svg_code)
{
        try
        {
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
                        
ByteArrayInputStream bais = new
ByteArrayInputStream(svg_code.getBytes());
                        
String parser = XMLResourceDescriptor.getXMLParserClassName();
                        
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
f.setValidating(false);

Document svgDocument = f.createSVGDocument(null, stream);

return (SVGDocument) svgDocument;
}
catch (Exception e)
{
        e.printStackTrace();
        return null;
}
}

/////////////////////////////////////////
while printing the code on the console, I get this (false) DTD
settings...

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg ...


///////////////////////////////////////

now I want to transform the SVGDocument via XSLT...

public void convertXML2FO(File xml, File xslt, File fo) throws
IOException, TransformerException
{
        //Setup output
        OutputStream out = new java.io.FileOutputStream(fo);
        try
        {
                //Setup XSLT
        TransformerFactory factory = TransformerFactory.newInstance();
                        
        Transformer transformer = factory.newTransformer(new
StreamSource(xslt));

        //Setup input for XSLT transformation
        Source src = new StreamSource(xml);

        //Resulting SAX events (the generated FO) must be piped through
to FOP
        Result res = new StreamResult(out);

        //Start XSLT transformation and FOP processing
        transformer.transform(src, res);
}
        finally
        {
                out.close();
        }
} 

///////////////////////////////////////

at this time a get an exception (java.net.UnknownHostException:
www.w3.org), because the upper DTD
('http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd') need to
vailidate...

I don’t know to tell batik to take the DTD local... did anybody know the
solution? (please give me a code example...) 


-----Ursprüngliche Nachricht-----
Von: Thomas DeWeese [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 18. März 2004 14:39
An: Batik Users
Betreff: **SPAM** Re: Local DTD for SVGDocument

[EMAIL PROTECTED] wrote:

> When Batik generates the SVGDocument, it sets the DTD like this
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"; But I need
to set the DTD
> local, because my Batik runs in a closed enviroment without any
internet
> connection. I think I need to use a EntityResolver, but I don´t know
to handle this.
> Has anybody a code example to solve my problem?  

Hi Sotto,

    Batik already includes an EntityResolver that maps well known
DTD decls to a local DTD.  So something must be broken in how
you are reading the files, perhaps you aren't using the Batik
classes to read the document, or perhaps the local copies of the
DTD got lost?



---------------------------------------------------------------------
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]

Reply via email to