[jdom-interest] Fwd: Fwd: JDOM to Xalan?

Rabinovich, Igor irabinov at mdsi.bc.ca
Thu Dec 7 15:35:52 PST 2000


Just by convertion to String and back.

public static void printContents(org.jdom.Document xmlDoc, String
xslFilename, PrintStream out)
throws SAXException, IOException {
	// processor
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new
XercesLiaison());

      String docStr = document2string(xmlDoc);
      if (docStr == null)
      	return;

	// XML source
      XSLTInputSource xml = new
XSLTInputSource(getInputSourceFromString(docStr));

	// XSL source
      StylesheetRoot stylesheet = processor.processStylesheet(xslFilename);
      processor.setStylesheet(stylesheet);

	// target
      DocumentHandler dh = stylesheet.getSAXSerializer(out);
	XSLTResultTarget html = new XSLTResultTarget(dh);

	processor.process(xml, null, html);
}

private static InputSource getInputSourceFromString(String xmlBuffer) {
	return new InputSource(new StringReader(xmlBuffer));
}

public static String document2string(org.jdom.Document doc) {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();

      XMLOutputter out = new XMLOutputter("     ", true);
      try {
      	out.output(doc, baos);
      } catch (IOException e) {
      	e.printStackTrace();
	      return null;
      }

      return baos.toString();
}


Igor Rabinovich.

-----Original Message-----
From: Al Yurov [mailto:alml at incap.ru]
Sent: Thursday, November 23, 2000 5:55 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Fwd: Fwd: JDOM to Xalan?


Hi!

How can I use Xalan with JDOM? Convert JDOM to DOM and give to Xalan?

and

how can I use org.w3c.dom.* and org.jdom.* in one class (they both
have Document class), only with full package name?
  

-- 
Best regards,
              Al                            mailto:alml at incap.ru

P.S. Sorry if this is duplicated message


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list