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 hans steen <ha...@hotmail.com> on 2001/03/26 15:50:30 UTC

problem with passing Xerces Document to Xalan

Can anyone tell me what is wrong.
I'm using Xerces to make an Document-object in this way:

  doc= new DocumentImpl();
  Element root = doc.createElement("dices:nshans");
  root.setAttribute("xmlns:dices", "http://www.hans.com");

  Element item = doc.createElement("dices:result");
  item.appendChild(doc.createTextNode("value"));
  root.appendChild(item);

  doc.appendChild( root );

Next I want to do is transform the output with Xalan to Html in this way:

  TransformerFactory tFactory = TransformerFactory.newInstance();
  StreamSource mysource = new StreamSource(new File("F:\\foo.xsl"));
  Transformer transformer = tFactory.newTransformer(mysource);

  DOMSource source = new DOMSource();
  source.setNode(objdoc);

  StreamResult result = new StreamResult();
  result.setWriter(out);

  transformer.transform(source, result);

The problem is that this outputs nothing.
When I parse a xml-file or a string with Xerces, this code works well with 
the above used Xsl-stylesheet, but when I want to pass the by Xerces made 
DOM Document nothing happens.

Is this a problem with the Document that Xerces makes or am I doing 
something wrong with the Xalan parse (DOMSource())?

Any help will be appreciated,
Hans
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: problem with passing Xerces Document to Xalan

Posted by Ian Roberts <ir...@decisionsoft.com>.
On Mon, 26 Mar 2001, hans steen wrote:

> Can anyone tell me what is wrong.
> I'm using Xerces to make an Document-object in this way:
> 
>   doc= new DocumentImpl();
>   Element root = doc.createElement("dices:nshans");
>   root.setAttribute("xmlns:dices", "http://www.hans.com");
> 
>   Element item = doc.createElement("dices:result");
>   item.appendChild(doc.createTextNode("value"));
>   root.appendChild(item);
> 
>   doc.appendChild( root );

I'm not sure this will create the correctly namespaced elements.  Try
doing:

Element root = doc.createElementNS("http://www.hans.com", "dices:nshans");
Element item = doc.createElementNS("http://www.hans.com", "dices:result");

to create the elements.

Ian

-- 
Ian Roberts, Software Engineer        DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org