You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Marlene Enslin <Ma...@discoveryworld.co.za> on 2001/07/26 08:56:24 UTC
node.getNamespaceURI Error
> Hi
>
> I am not sure if this is the right group to mail this to. I have been
> trying to solve this error for days now. I am using FOP to create a PDF
> document from a XSL file and XML file. I will use thi sin a servlet, but
> for now just to get the code working I am using a main method. I have
> copied the newest version of the DOM 4.
> Here's my code and the error is displayed below :
>
> import java.io.File.*;
> import java.io.IOException;
> import java.io.*;
> import java.util.*;
> import javax.xml.transform.Transformer;
> import javax.xml.parsers.SAXParserFactory;
> import javax.xml.transform.sax.*;
>
> //Apache
> import org.apache.fop.apps.Driver;
> import org.apache.fop.apps.Options;
> import org.apache.fop.apps.XSLTInputHandler;
> import org.apache.fop.tools.DocumentInputSource;
> import org.apache.fop.render.pdf.PDFRenderer;
> import org.apache.xerces.parsers.SAXParser;
> import org.apache.fop.extensions.ExtensionPropertyListMapping;
>
>
> import org.apache.fop.apps.FOPException;
> import org.apache.fop.apps.InputHandler;
>
> import org.apache.fop.tools.*;
> import org.apache.fop.svg.*;
>
> import org.apache.fop.fo.properties.*;
> import org.apache.fop.fo.FOTreeBuilder;
>
> import org.apache.fop.fo.ElementMapping;
>
> import org.apache.xalan.processor.*;
> import org.apache.xml.utils.*;
> import org.apache.xpath.*;
> import org.apache.crimson.jaxp.*;
>
> //Sax
> import org.xml.sax.InputSource;
> import org.xml.sax.SAXException;
> import org.xml.sax.XMLReader;
> import org.xml.sax.SAXNotRecognizedException;
> import org.xml.sax.SAXNotSupportedException;
>
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.NamedNodeMap;
> import org.w3c.dom.NodeList;
> import org.w3c.dom.DOMException.*;
>
> import com.sun.xml.parser.*;
>
> import com.sun.jimi.core.compat.*;
> import com.sun.jimi.core.component.*;
> import com.sun.jimi.core.*;
> import com.sun.jimi.core.decoder.gif.*;
> import com.sun.jimi.core.filters.*;
> import com.sun.jimi.core.options.*;
> import com.sun.jimi.core.raster.*;
> import com.sun.jimi.core.util.*;
> import com.sun.jimi.core.vmem.*;
>
> import org.apache.xerces.framework.XMLParser;
>
>
> public class FOPCreatePDF
> {
>
>
> static String createPDF(File xmlFile, File xslFile) throws Exception
> {
> File anXMLFile = new File("c:\\xml-fop\\",
> "12month_exclusion.xml");
> File anXSLFile = new File("c:\\xml-fop\\",
> "12month_exclusion.xsl");
>
> final XSLTInputHandler xsltInputHandler = new
> XSLTInputHandler(anXMLFile, anXSLFile);
>
> final org.xml.sax.InputSource inputSource =
> xsltInputHandler.getInputSource();
>
>
> try{
>
> final XMLReader parser =
> xsltInputHandler.getParser();
> final Driver driver = new Driver();
> driver.setRenderer(Driver.RENDER_PDF);
>
>
> driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
>
>
> driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
>
> driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMappin
> g");
>
>
> driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
>
> driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
>
>
> driver.setInputSource(inputSource);
> driver.buildFOTree(parser, inputSource);
> driver.format();
>
> final FileOutputStream fileOutputStream =
> new
> FileOutputStream("c:\\xml-fop\\testmenow.pdf");
> driver.setOutputStream(fileOutputStream);
> driver.render();
> fileOutputStream.close();
>
>
> }catch(FOPException fopE){
> ByteArrayOutputStream byteArrayOutputStream = new
> ByteArrayOutputStream();
> PrintStream printStream = new
> PrintStream(byteArrayOutputStream);
> fopE.printStackTrace(printStream);
>
> throw new Exception(fopE.getMessage() + "\n" +
> byteArrayOutputStream.toString());
> }catch(Exception ex){
> ByteArrayOutputStream byteArrayOutputStream = new
> ByteArrayOutputStream();
> PrintStream printStream = new
> PrintStream(byteArrayOutputStream);
> ex.printStackTrace(printStream);
>
> throw new Exception(ex.getMessage() + "\n" +
> byteArrayOutputStream.toString());
>
> }
>
> return "c:\\xml-fop\\testmenow.pdf";
>
>
> }
>
> public static void main(String[] args)
> {
> try{
> createPDF(xmlFile, xslFile);
> }catch(Exception e){
> e.printStackTrace(System.err);
> }
> }
>
>
>
> }//End:Class
>
> <<...OLE_Obj...>>
>
> I would appreciate it alot if anyone can help me. I have been battleling
> with this, and searching Google to find any answers and what I have been
> trying didn't worked.
>
>
> Marlene Enslin
> Java Developer
> marlene@discoveryworld.co.za
> +2711 529 3503
> DiscoveryWorld
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org