xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xue, Feng" <feng....@Mobility.com>
Subject Child Text Node lost after calling newDomNode()
Date Tue, 20 Apr 2004 15:43:21 GMT
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-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message