Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue [message #24708] |
Wed, 09 July 2003 14:00  |
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. According to the Javadoc for XSDAnnotation.getUserInformation
the contents of the list are of type Element:
<p><tt> /**</tt>
<br><tt> * Returns the value of the '<em><b>User Information</b></em>'
attribute list.</tt>
<br><tt> * 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: public String getNodeValue() {</tt>
<br><tt>CharacterDataImpl.java: public String getNodeValue()
{</tt>
<br><tt>DeferredDocumentImpl.java: public String getNodeValueString(int
nodeIndex) {</tt>
<br><tt>DeferredDocumentImpl.java: public String getNodeValueString(int
nodeIndex, boolean free) {</tt>
<br><tt>DeferredDocumentImpl.java: public String getNodeValue(int
nodeIndex) {</tt>
<br><tt>DeferredDocumentImpl.java: public String getNodeValue(int
nodeIndex, boolean free) {</tt>
<br><tt> DeferredDocumentTypeImpl.java:
publicID = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt> DeferredEntityImpl.java: &n bsp;
publicId = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt> DeferredNotationImpl.java: & ;nbsp;
publicId = ownerDocument.getNodeValue(fNodeIndex);</tt>
<br><tt>NodeImpl.java: public String getNodeValue() {</tt></blockquote>
And since getNodeValue is implemented like this in NodeImpl:
<p><tt> public String getNodeValue() {</tt>
<br><tt> return null; & nbsp;
// overridden in some subclasses</tt>
<br><tt> }</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.
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>
<p>Bodo wrote:
<blockquote TYPE=CITE>hi,
<br>my schema contains this attribute definition:
<br>.....
<br><xs:attribute name="testattrib">
<br> <xs:annotation>
<br>
<xs:documentation>test text 1 </xs:documentation>
<br> </xs:annotation>
<br> <xs:simpleType>
<br>
<xs:annotation>
<br>
<xs:documentation>test text 2</xs:documentation>
<br>
</xs:annotation>
<br>
<xs:restriction base="xs:string">
<br>
<xs:pattern value="\s*\d+(\.\d+)?\s*pt\s*"/>
<p>
</xs:restriction>
<br>
</xs:simpleType>
<br></xs:attribute>
<br>....
<br>and i try to access the documentation using this code:
<br>("attrib" represents the "testattrib" object)
<p>XSDAnnotation anno =
<br> (XSDAttributeUse) attrib)getAttributeDeclaration().getAnnotation();
<br> userInfo = (Node) (anno.getUserInformation().get(0));
<br> System.out.println("value:"+userInfo.getNodeValue());
<p>XSDAnnotation anno =
<br> (XSDAttributeUse)attrib)getAttributeDeclaration().getTypeDef inition().getAnnotation();
<br> userInfo = (Node) (anno.getUserInformation().get(0));
<br> System.out.println("value:"+userInfo.getNodeValue());
<p>but 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 04:53  |
Eclipse User |
|
|
|
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 04:53  |
Eclipse User |
|
|
|
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
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03140 seconds