Re: getAnnotaion().getUserInfomation() returns an org.w3c.dom.Node withemty nodeValue [message #574020] |
Wed, 09 July 2003 18:00 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
--------------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--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03261 seconds