Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue
Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue [message #24708] Wed, 09 July 2003 18:00 Go to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

--------------3C1EF06144C3DA07E251CAD1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Bodo,

This is really a DOM question. According to the Javadoc for
XSDAnnotation.getUserInformation the contents of the list are of type Element:

/**
* Returns the value of the '<em><b>User Information</b></em>' attribute list.
* The list contents are of type {@link org.w3c.dom.Element}.

When I search the Xerces implementation in org/apache/xerces/dom I see this:

> grep public.*getNodeValue *.java
AttrImpl.java: public String getNodeValue() {
CharacterDataImpl.java: public String getNodeValue() {
DeferredDocumentImpl.java: public String getNodeValueString(int nodeIndex) {
DeferredDocumentImpl.java: public String getNodeValueString(int nodeIndex,
boolean free) {
DeferredDocumentImpl.java: public String getNodeValue(int nodeIndex) {
DeferredDocumentImpl.java: public String getNodeValue(int nodeIndex, boolean
free) {
DeferredDocumentTypeImpl.java: publicID =
ownerDocument.getNodeValue(fNodeIndex);
DeferredEntityImpl.java: publicId =
ownerDocument.getNodeValue(fNodeIndex);
DeferredNotationImpl.java: publicId =
ownerDocument.getNodeValue(fNodeIndex);
NodeImpl.java: public String getNodeValue() {

And since getNodeValue is implemented like this in NodeImpl:

public String getNodeValue() {
return null; // overridden in some subclasses
}

and isn't overridden in ElementImpl, I don't think you should be expected getNodeValue to
return something other than null for an Element. I think you should expect to find child
Text nodes of type Node.TEXT_NODE that hold, via getNodeValue, the information you are
trying to access.


Bodo wrote:

> hi,
> my schema contains this attribute definition:
> .....
> <xs:attribute name="testattrib">
> <xs:annotation>
> <xs:documentation>test text 1 </xs:documentation>
> </xs:annotation>
> <xs:simpleType>
> <xs:annotation>
> <xs:documentation>test text 2</xs:documentation>
> </xs:annotation>
> <xs:restriction base="xs:string">
> <xs:pattern value="\s*\d+(\.\d+)?\s*pt\s*"/>
>
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> ....
> and i try to access the documentation using this code:
> ("attrib" represents the "testattrib" object)
>
> XSDAnnotation anno =
> (XSDAttributeUse) attrib)getAttributeDeclaration().getAnnotation();
> userInfo = (Node) (anno.getUserInformation().get(0));
> System.out.println("value:"+userInfo.getNodeValue());
>
> XSDAnnotation anno =
> (XSDAttributeUse)attrib)getAttributeDeclaration().getTypeDef inition().getAnnotation();
> userInfo = (Node) (anno.getUserInformation().get(0));
> System.out.println("value:"+userInfo.getNodeValue());
>
> but always getNodeValue() return null.
>
> any ideas what is wrong here ?
> bodo

--------------3C1EF06144C3DA07E251CAD1
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Bodo,
<p>This is really a DOM question.&nbsp; According to the Javadoc for XSDAnnotation.getUserInformation
the contents of the list are of type Element:
<p><tt>&nbsp; /**</tt>
<br><tt>&nbsp;&nbsp; * Returns the value of the '&lt;em>&lt;b>User Information&lt;/b>&lt;/em>'
attribute list.</tt>
<br><tt>&nbsp;&nbsp; * The list contents are of type {@link <b>org.w3c.dom.Element</b>}.</tt><tt></tt>
<p>When I search the Xerces implementation in org/apache/xerces/dom I see
this:
<blockquote><tt>> grep public.*getNodeValue *.java</tt>
<br><tt>AttrImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValue() {</tt>
<br><tt>CharacterDataImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValue()
{</tt>
<br><tt>DeferredDocumentImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValueString(int
nodeIndex) {</tt>
<br><tt>DeferredDocumentImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValueString(int
nodeIndex, boolean free) {</tt>
<br><tt>DeferredDocumentImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValue(int
nodeIndex) {</tt>
<br><tt>DeferredDocumentImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValue(int
nodeIndex, boolean free) {</tt>
<br><tt> DeferredDocumentTypeImpl.java:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
publicID = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt> DeferredEntityImpl.java:&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;
publicId&nbsp;&nbsp;&nbsp; = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt> DeferredNotationImpl.java:&nbsp;&nbsp;&nbsp;& ;nbsp;&nbsp;&nbsp;&nbsp;
publicId = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt>NodeImpl.java:&nbsp;&nbsp;&nbsp; public String getNodeValue() {</tt></blockquote>
And since getNodeValue is implemented like this in NodeImpl:
<p><tt>&nbsp;&nbsp;&nbsp; public String getNodeValue() {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// overridden in some subclasses</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<p>and isn't overridden in ElementImpl, I don't think you should be expected
getNodeValue to return something other than null for an Element.&nbsp;
I think you should expect to find child Text nodes of type Node.TEXT_NODE
that hold, via getNodeValue, the information you are trying to access.
<br>&nbsp;
<p>Bodo wrote:
<blockquote TYPE=CITE>hi,
<br>my schema contains this attribute definition:
<br>.....
<br>&lt;xs:attribute name="testattrib">
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &lt;xs:annotation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;xs:documentation>test text 1 &lt;/xs:documentation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &lt;/xs:annotation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xs:simpleType>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&lt;xs:annotation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&lt;xs:documentation>test text 2&lt;/xs:documentation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&lt;/xs:annotation>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&lt;xs:restriction base="xs:string">
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&lt;xs:pattern value="\s*\d+(\.\d+)?\s*pt\s*"/>
<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&lt;/xs:restriction>
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/xs:simpleType>
<br>&lt;/xs:attribute>
<br>....
<br>and i try to access the documentation using this code:
<br>("attrib" represents the "testattrib" object)
<p>XSDAnnotation anno =
<br>&nbsp;&nbsp; (XSDAttributeUse) attrib)getAttributeDeclaration().getAnnotation();
<br>&nbsp;&nbsp; userInfo = (Node) (anno.getUserInformation().get(0));
<br>&nbsp;&nbsp; System.out.println("value:"+userInfo.getNodeValue());
<p>XSDAnnotation anno =
<br> (XSDAttributeUse)attrib)getAttributeDeclaration().getTypeDef inition().getAnnotation();
<br>&nbsp;&nbsp; userInfo = (Node) (anno.getUserInformation().get(0));
<br>&nbsp;&nbsp; System.out.println("value:"+userInfo.getNodeValue());
<p>but&nbsp; always getNodeValue() return null.
<p>any ideas what is wrong here ?
<br>bodo</blockquote>
</html>

--------------3C1EF06144C3DA07E251CAD1--
Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue [message #24748 is a reply to message #24708] Thu, 10 July 2003 08:53 Go to previous message
Bodo is currently offline Bodo
Messages: 7
Registered: July 2009
Junior Member
Thank you! (I'm not really a Dom expert, i used only Jdom in the past)
Now I got it working:
Before, I was wondering, why i did not see any test-data of the Node in
my debugger-variable-view . Seems it is generated not before one really
asks for the data using some code sequence like this:

userInfo = (org.w3c.dom.Element) (annotation.getUserInformation().get(0));
if (userInfo != null) {
NodeList chNodes = userInfo.getChildNodes();
if (chNodes.getLength() > 0) {
Node tst = chNodes.item(0);
if (tst instanceof org.w3c.dom.Text)
cat.debug(((org.w3c.dom.Text)
tst).getData());// here comes my test text data!
}
}

Bodo


Ed Merks schrieb:

> Bodo,
>
> This is really a DOM question. According to the Javadoc for
> XSDAnnotation.getUserInformation the contents of the list are of type
> Element:
>
> /**
> * Returns the value of the '<em><b>User Information</b></em>'
> attribute list.
> * The list contents are of type {@link *org.w3c.dom.Element*}.
>
> When I search the Xerces implementation in org/apache/xerces/dom I see
> this:
>
> > grep public.*getNodeValue *.java
> AttrImpl.java: public String getNodeValue() {
> CharacterDataImpl.java: public String getNodeValue() {
> DeferredDocumentImpl.java: public String getNodeValueString(int
> nodeIndex) {
> DeferredDocumentImpl.java: public String getNodeValueString(int
> nodeIndex, boolean free) {
> DeferredDocumentImpl.java: public String getNodeValue(int
> nodeIndex) {
> DeferredDocumentImpl.java: public String getNodeValue(int
> nodeIndex, boolean free) {
> DeferredDocumentTypeImpl.java: publicID =
> ownerDocument.getNodeValue(fNodeIndex);
> DeferredEntityImpl.java: publicId =
> ownerDocument.getNodeValue(fNodeIndex);
> DeferredNotationImpl.java: publicId =
> ownerDocument.getNodeValue(fNodeIndex);
> NodeImpl.java: public String getNodeValue() {
>
> And since getNodeValue is implemented like this in NodeImpl:
>
> public String getNodeValue() {
> return null; // overridden in some subclasses
> }
>
> and isn't overridden in ElementImpl, I don't think you should be
> expected getNodeValue to return something other than null for an
> Element. I think you should expect to find child Text nodes of type
> Node.TEXT_NODE that hold, via getNodeValue, the information you are
> trying to access.
>
>
> Bodo wrote:
>
>> hi,
>> my schema contains this attribute definition:
>> .....
>> <xs:attribute name="testattrib">
>> <xs:annotation>
>> <xs:documentation>test text 1 </xs:documentation>
>> </xs:annotation>
>> <xs:simpleType>
>> <xs:annotation>
>> <xs:documentation>test text 2</xs:documentation>
>> </xs:annotation>
>> <xs:restriction base="xs:string">
>> <xs:pattern value="\s*\d+(\.\d+)?\s*pt\s*"/>
>>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:attribute>
>> ....
>> and i try to access the documentation using this code:
>> ("attrib" represents the "testattrib" object)
>>
>> XSDAnnotation anno =
>> (XSDAttributeUse) attrib)getAttributeDeclaration().getAnnotation();
>> userInfo = (Node) (anno.getUserInformation().get(0));
>> System.out.println("value:"+userInfo.getNodeValue());
>>
>> XSDAnnotation anno =
>> (XSDAttributeUse)attrib)getAttributeDeclaration().getTypeDef inition().getAnnotation();
>> userInfo = (Node) (anno.getUserInformation().get(0));
>> System.out.println("value:"+userInfo.getNodeValue());
>>
>> but always getNodeValue() return null.
>>
>> any ideas what is wrong here ?
>> bodo
>>
Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue [message #574050 is a reply to message #24708] Thu, 10 July 2003 08:53 Go to previous message
Bodo is currently offline Bodo
Messages: 7
Registered: July 2009
Junior Member
Thank you! (I'm not really a Dom expert, i used only Jdom in the past)
Now I got it working:
Before, I was wondering, why i did not see any test-data of the Node in
my debugger-variable-view . Seems it is generated not before one really
asks for the data using some code sequence like this:

userInfo = (org.w3c.dom.Element) (annotation.getUserInformation().get(0));
if (userInfo != null) {
NodeList chNodes = userInfo.getChildNodes();
if (chNodes.getLength() > 0) {
Node tst = chNodes.item(0);
if (tst instanceof org.w3c.dom.Text)
cat.debug(((org.w3c.dom.Text)
tst).getData());// here comes my test text data!
}
}

Bodo


Ed Merks schrieb:

> Bodo,
>
> This is really a DOM question. According to the Javadoc for
> XSDAnnotation.getUserInformation the contents of the list are of type
> Element:
>
> /**
> * Returns the value of the '<em><b>User Information</b></em>'
> attribute list.
> * The list contents are of type {@link *org.w3c.dom.Element*}.
>
> When I search the Xerces implementation in org/apache/xerces/dom I see
> this:
>
> > grep public.*getNodeValue *.java
> AttrImpl.java: public String getNodeValue() {
> CharacterDataImpl.java: public String getNodeValue() {
> DeferredDocumentImpl.java: public String getNodeValueString(int
> nodeIndex) {
> DeferredDocumentImpl.java: public String getNodeValueString(int
> nodeIndex, boolean free) {
> DeferredDocumentImpl.java: public String getNodeValue(int
> nodeIndex) {
> DeferredDocumentImpl.java: public String getNodeValue(int
> nodeIndex, boolean free) {
> DeferredDocumentTypeImpl.java: publicID =
> ownerDocument.getNodeValue(fNodeIndex);
> DeferredEntityImpl.java: publicId =
> ownerDocument.getNodeValue(fNodeIndex);
> DeferredNotationImpl.java: publicId =
> ownerDocument.getNodeValue(fNodeIndex);
> NodeImpl.java: public String getNodeValue() {
>
> And since getNodeValue is implemented like this in NodeImpl:
>
> public String getNodeValue() {
> return null; // overridden in some subclasses
> }
>
> and isn't overridden in ElementImpl, I don't think you should be
> expected getNodeValue to return something other than null for an
> Element. I think you should expect to find child Text nodes of type
> Node.TEXT_NODE that hold, via getNodeValue, the information you are
> trying to access.
>
>
> Bodo wrote:
>
>> hi,
>> my schema contains this attribute definition:
>> .....
>> <xs:attribute name="testattrib">
>> <xs:annotation>
>> <xs:documentation>test text 1 </xs:documentation>
>> </xs:annotation>
>> <xs:simpleType>
>> <xs:annotation>
>> <xs:documentation>test text 2</xs:documentation>
>> </xs:annotation>
>> <xs:restriction base="xs:string">
>> <xs:pattern value="\s*\d+(\.\d+)?\s*pt\s*"/>
>>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:attribute>
>> ....
>> and i try to access the documentation using this code:
>> ("attrib" represents the "testattrib" object)
>>
>> XSDAnnotation anno =
>> (XSDAttributeUse) attrib)getAttributeDeclaration().getAnnotation();
>> userInfo = (Node) (anno.getUserInformation().get(0));
>> System.out.println("value:"+userInfo.getNodeValue());
>>
>> XSDAnnotation anno =
>> (XSDAttributeUse)attrib)getAttributeDeclaration().getTypeDef inition().getAnnotation();
>> userInfo = (Node) (anno.getUserInformation().get(0));
>> System.out.println("value:"+userInfo.getNodeValue());
>>
>> but always getNodeValue() return null.
>>
>> any ideas what is wrong here ?
>> bodo
>>
Previous Topic:Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue
Next Topic:ResourceSetImpl.getResource exception
Goto Forum:
  


Current Time: Wed Sep 24 02:27:02 GMT 2014

Powered by FUDForum. Page generated in 0.02759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software