If your application is directly inovking Xerces' simple type validators, 
then it's responsible for providing a namespace context for QNames. Have a 
look at org.apache.xerces.impl.validation.ValidationState (see 
getURI(String)). It should give you some idea on how to do that.

VASEUX Micka�l <[EMAIL PROTECTED]> wrote on 04/08/2005 
03:27:07 AM:

> Thank you very much for solving this bug !!!
> Now I haven't exception anymore.
> But when I try to validate the QName "xsd:string", the API says the 
> value is incorrect :
> 
> UndeclaredPrefix: Cannot resolve 'xsd:string' as a QName: the prefix 
> 'xsd' is not declared.
> 
> Here is my Schema :
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
> xmlns:n0="http://www.w3.org/XML/1998/namespace";>
>     <xsd:annotation>
>         <xsd:documentation xml:lang="fr">
>       Schema XML d'une activite Symba.
>     </xsd:documentation>
>     </xsd:annotation> 
>     <xsd:element name="Activite" type="typeActivite"/>
>     <xsd:complexType name="typeActivite">
>         <xsd:sequence>
>             <xsd:element name="nom" type="xsd:string"/>
>             <xsd:element name="etape" type="typeetape" 
> maxOccurs="unbounded"/>
>         </xsd:sequence>
>     </xsd:complexType>
>     <xsd:complexType name="typeetape">
>         <xsd:sequence>
>             <xsd:element name="nom" type="xsd:string"/>
>             <xsd:element name="plan" type="typeplan"/>
>             <xsd:element name="prec-ref" type="xsd:IDREF" 
minOccurs="0"/>
>             <xsd:element name="suiv-ref" type="xsd:IDREF" 
minOccurs="0"/>
>         </xsd:sequence>
>         <xsd:attribute name="identifier"  type="xsd:ID" use="required"/>
>     </xsd:complexType>
>     <xsd:complexType name="typeplan">
>         <xsd:sequence>
>             <xsd:element name="tache" type="typetache" 
> maxOccurs="unbounded"/>
>         </xsd:sequence>
>     </xsd:complexType>
>     <xsd:complexType name="typetache">
>         <xsd:sequence>
>             <xsd:element name="titre" type="xsd:string"/>
>             <xsd:element name="acteur" type="xsd:string"/>
>             <xsd:element name="entrees" type="xsd:string"/>
>             <xsd:element name="sorties" type="xsd:string"/>
>             <xsd:element name="dates" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> 
> 
> Have you an idea about this error? Is it normal?
> 
> 
> 
> 
> Michael Glavassevich (JIRA) a �crit :
> 
> >     [ 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
> >> 
> >>
> >
> > 
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to