You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Xue, Feng" <fe...@Mobility.com> on 2004/04/20 17:43:21 UTC

Child Text Node lost after calling newDomNode()

Hello, 

I have a simple custom XMLBean compiled from a schema like:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://mydomain.com/xsd/myBean"
 xmlns="http://www.w3.org/2001/XMLSchema"
 xmlns:tns="http://mydomain.com/xsd/myBean"
 elementFormDefault="qualified">

 <simpleType name="MyType">
  <restriction base="double"/>
 </simpleType>

 <element name="MyElement" type="tns:MyType"/>

</schema>

An the Java code:

import com.mydomain.xsd.myBean.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

...
...

void myMethod() {
  MyElementDocument  bean = MyElementDocument.Factory.newInstance();
  bean.setMyElement(3.14d);
  // this prints the the xml with text including 3.14d
  System.out.println(bean.xmlText());
  
  Element dom = ((Document) bean.newDomNode()) .getDocumentElement();
  ...
}


The problem is, after getting the DOM object my calling newDomNode(), the
Text Node for "3.14d" is lost from the DOM tree; i.e. instead of

<tns:MyElement
xmlns:tns="http://mydomain.com/xsd/myBean">3.14d</tns:MyElement>

I get XML like:

<tns:MyElement  xmlns:tns="http://mydomain.com/xsd/myBean" />

Question: how come the DOM tree is not complete?

Any help is very much appreciated.

-Feng

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/