You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2005/04/07 19:49:19 UTC

[jira] Resolved: (XERCESJ-1059) NullPointerException with class QNameDV method getActualValue

     [ http://issues.apache.org/jira/browse/XERCESJ-1059?page=history ]
     
Michael Glavassevich resolved XERCESJ-1059:
-------------------------------------------

    Resolution: Fixed

ValidationContext.getSymbol() is not allowed to return null. It must return a unique string equal to the one passed in. When used in conjunction with the parser, this unique string must be the same string that would be returned from String.intern(). There were a couple internal ValidationContext implementations which were returning null. I've fixed those in CVS.

User implementations of ValidationContext are responsible for returning unique strings from getSymbol(). If QNameDV is receiving null from the ValidationContext, it's a bug in the ValidationContext implementation.

> NullPointerException with class QNameDV method getActualValue
> -------------------------------------------------------------
>
>          Key: XERCESJ-1059
>          URL: http://issues.apache.org/jira/browse/XERCESJ-1059
>      Project: Xerces2-J
>         Type: Bug
>   Components: XML Schema API
>     Versions: 2.6.2
>  Environment: Windows XP SP2 JRE 1.4.2_06-b03
>     Reporter: vaseux mickael

>
> Sorry For My English I'm french user of Xerces API !!!
> Consequences :
> NullPointerException with Xample Editor when using XMLSchema.xsd.
> Here's the exception :
> java.lang.NullPointerException
> 	at org.apache.xerces.impl.dv.xs.QNameDV.getActualValue(QNameDV.java:105)
> 	at org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.getActualValue(Unknown Source)
> 	at org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.validate(Unknown Source)
> 	at com.fg.xmleditor.XSRef.validate(XSRef.java:119)
> 	at com.fg.xmleditor.Validator.isValid(Validator.java:122)
> Her's the code of the method :
> public Object getActualValue(String content, ValidationContext context)
>        throws InvalidDatatypeValueException {
>        // "prefix:localpart" or "localpart"
>        // get prefix and local part out of content
>        String prefix, localpart;
>        int colonptr = content.indexOf(":");
>        if (colonptr > 0) {
>            prefix = context.getSymbol(content.substring(0,colonptr));
>            localpart = content.substring(colonptr+1);
>        } else {
>            prefix = EMPTY_STRING;
>            localpart = content;
>        }
>        // both prefix (if any) a nd localpart must be valid NCName
>        if (*prefix.length() > 0* && !XMLChar.isValidNCName(prefix))
>            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
>        if(!XMLChar.isValidNCName(localpart))
>            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
>        // resove prefix to a uri, report an error if failed
>        String uri = context.getURI(prefix);
>        if (prefix.length() > 0 && uri == null)
>            throw new InvalidDatatypeValueException("UndeclaredPrefix", new Object[]{content, prefix});
>        return new XQName(prefix, context.getSymbol(localpart), context.getSymbol(content), uri);
>    }
> In fact, the function : context.getSymbol(content.substring(0,colonptr)) return the null value, and there's no test to see if the value returned is null or not.
> Tere's is some tests after in order to see if length() is > 0 or not, that's show that the developper thinked that getSymbol return ALWAYS a String, which is empty if the symbol hasn't be found. 
> Solution : 
> If the function return null value, the prefix String must be set with an EMPTY_STRING.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org