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

    Resolution: Duplicate

Duplicate of XERCESJ-1059.

> NullPointerException with class QNameDV method getActualValue
> -------------------------------------------------------------
>
>          Key: XERCESJ-1057
>          URL: http://issues.apache.org/jira/browse/XERCESJ-1057
>      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 ...
> Consequence : get a nullPointerException in Xample when using XMLSchema.xsd 
> and set "type" attribute of an element with a prefix (example : "xs:string")
> Here is 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)
> Here is 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.
> There's is some tests, after, in order to see if prefix.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. In relity, yhe context 
> can be return a null value in case of Dummy Context or Empty Context (see 
> XSSimpleTypeDecl.class)
> Solution : if the function return null, the prefix String must be set with 
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to