From commitsjohnsonbrian@example.com Sat Apr 02 02:39:26 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 1194 invoked from network); 2 Apr 2005 02:39:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Apr 2005 02:39:26 -0000 Received: (qmail 70049 invoked by uid 500); 2 Apr 2005 02:39:26 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 70015 invoked by uid 500); 2 Apr 2005 02:39:25 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 70000 invoked by uid 99); 2 Apr 2005 02:39:25 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 01 Apr 2005 18:39:21 -0800 Received: (qmail 1180 invoked by uid 65534); 2 Apr 2005 02:39:20 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Sat, 02 Apr 2005 02:39:20 -0000 Subject: svn commit: r159751 - in xmlbeans/trunk: src/common/org/apache/xmlbeans/impl/common/ src/typeimpl/org/apache/xmlbeans/impl/schema/ src/typeimpl/org/apache/xmlbeans/impl/validator/ src/xmlpublic/org/apache/xmlbeans/ test/src/compile/scomp/checkin/ To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: radup Date: Fri Apr 1 18:39:18 2005 New Revision: 159751 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D159751 Log: Reviewed some validation/Schema compilation error reporting. Modified: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/IdentityConst= raint.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeV= isitorImpl.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker= .java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaize= r=2Ejava xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleT= ypeResolver.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validato= r=2Ejava xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java Modified: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/Identit= yConstraint.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/common/org/apache/xml= beans/impl/common/IdentityConstraint.java?view=3Ddiff&r1=3D159750&r2=3D1597= 51 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/IdentityConst= raint.java (original) +++ xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/IdentityConst= raint.java Fri Apr 1 18:39:18 2005 @@ -373,7 +373,8 @@ if (fields.unfilled() < 0 && ! hasKeyValue(fields)) { // KHK: cvc-identity-constraint.4.3 ? - emitError(e, "Key '" + fields + "' not found (keyRef "= + QNameHelper.pretty(_constraint.getName()) + ")"); + emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$KEYR= EF_KEY_NOT_FOUND, + new Object[] {fields, QNameHelper.pretty(_constraint.= getName())}); return; } } Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem= aTypeVisitorImpl.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/SchemaTypeVisitorImpl.java?view=3Ddiff&r1=3D159750&r2= =3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeV= isitorImpl.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeV= isitorImpl.java Fri Apr 1 18:39:18 2005 @@ -100,7 +100,11 @@ _curMax =3D orig._curMax; _processedChildCount =3D orig._processedChildCount; _childCount =3D orig._childCount; - _seen =3D orig._seen; + if (orig._seen !=3D null) + { + _seen =3D new boolean[orig._seen.length]; + System.arraycopy(orig._seen, 0, _seen, 0, orig._seen.lengt= h); + } } =20 public void init(SchemaParticle part) Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscC= hecker.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/StscChecker.java?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker= .java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker= .java Fri Apr 1 18:39:18 2005 @@ -1593,32 +1593,35 @@ =20 if (! headType.isAssignableFrom(tailType)) { - state.error("Element " + QNameHelper.pretty(elt.getNam= e()) + - " must have a type that is derived from the type o= f its substitution group.", - XmlErrorCodes.INCONSISTENT_TYPE, parseTree); - =20 + state.error(XmlErrorCodes.ELEM_PROPERTIES$SUBSTITUTION= _VALID, + new Object[] {QNameHelper.pretty(elt.getName()), + QNameHelper.pretty(head.getName())}, + parseTree); } else if (head.finalExtension() && head.finalRestriction()) { - state.error("Element " + QNameHelper.pretty(elt.getNam= e()) +=20 - " cannot be substituted for element with final=3D'= #all'", - XmlErrorCodes.CANNOT_DERIVE_FINAL, parseTree); + state.error(XmlErrorCodes.ELEM_PROPERTIES$SUBSTITUTION= _FINAL, + new Object[] {QNameHelper.pretty(elt.getName()), + QNameHelper.pretty(head.getName()), + "#all"}, parseTree); } else if (! headType.equals(tailType)) { if (head.finalExtension() &&=20 tailType.getDerivationType() =3D=3D SchemaTyp= e=2EDT_EXTENSION) { - state.error("Element " + QNameHelper.pretty(elt.ge= tName()) +=20 - " cannot be substituted for element with final= =3D'extension'", - XmlErrorCodes.CANNOT_DERIVE_FINAL, parseTree); + state.error(XmlErrorCodes.ELEM_PROPERTIES$SUBSTITU= TION_FINAL, + new Object[] {QNameHelper.pretty(elt.getName()= ), + QNameHelper.pretty(head.getName(= )), + "extension"}, parseTree); } else if (head.finalRestriction() && tailType.getDerivationType() =3D=3D SchemaTyp= e=2EDT_RESTRICTION) { - state.error("Element " + QNameHelper.pretty(elt.ge= tName()) +=20 - " cannot be substituted for element with final= =3D'restriction'", - XmlErrorCodes.CANNOT_DERIVE_FINAL, parseTree); + state.error(XmlErrorCodes.ELEM_PROPERTIES$SUBSTITU= TION_FINAL, + new Object[] {QNameHelper.pretty(elt.getName()= ), + QNameHelper.pretty(head.getName(= )), + "restriction"}, parseTree); } } } Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJ= avaizer.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/StscJavaizer.java?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaize= r=2Ejava (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaize= r=2Ejava Fri Apr 1 18:39:18 2005 @@ -279,7 +279,7 @@ =20 // assign java type names to anonymous types // for redefined types, this step was performed when javaizing the= redefinition - if (sImpl.getFullJavaName() !=3D null) + if (sImpl.getFullJavaName() !=3D null || sImpl.getOuterType() !=3D= null) assignJavaAnonymousTypeNames(sImpl); =20 sImpl.finishJavaizing(); Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscS= impleTypeResolver.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/StscSimpleTypeResolver.java?view=3Ddiff&r1=3D159750&r2= =3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleT= ypeResolver.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleT= ypeResolver.java Fri Apr 1 18:39:18 2005 @@ -833,7 +833,25 @@ { // note: this guarantees that the limit is a v= alid number in the // base data type!! - state.error("Must be valid value in base type:= " + e.getMessage(), XmlErrorCodes.FACET_VALUE_MALFORMED, facet); + switch (code) + { + case SchemaType.FACET_MIN_EXCLUSIVE: + state.error(XmlErrorCodes.DATATYPE_MIN_EXC= LUSIVE_RESTRICTION, + new Object[] {e.getMessage()}, facet); + break; + case SchemaType.FACET_MIN_INCLUSIVE: + state.error(XmlErrorCodes.DATATYPE_MIN_INC= LUSIVE_RESTRICTION, + new Object[] {e.getMessage()}, facet); + break; + case SchemaType.FACET_MAX_INCLUSIVE: + state.error(XmlErrorCodes.DATATYPE_MAX_INC= LUSIVE_RESTRICTION, + new Object[] {e.getMessage()}, facet); + break; + case SchemaType.FACET_MAX_EXCLUSIVE: + state.error(XmlErrorCodes.DATATYPE_MAX_EXC= LUSIVE_RESTRICTION, + new Object[] {e.getMessage()}, facet); + break; + } =20 // BUGBUG: if there are actual schemas that re= define min/maxExclusive, // they will need this rule relaxed for them!! Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Va= lidator.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/validator/Validator.java?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validato= r=2Ejava (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validato= r=2Ejava Fri Apr 1 18:39:18 2005 @@ -595,6 +595,13 @@ _eatContent =3D 1; return; } + =20 + if (isNil && elementField !=3D null && elementField.isFixed()) + { + emitFieldError( event, XmlErrorCodes.ELEM_LOCALLY_VALID$NIL_WI= TH_FIXED, null, + elementField =3D=3D null ? null : elementField.getName(), = elementType, null, + XmlValidationError.ELEMENT_TYPE_INVALID, (state =3D=3D nul= l ? null : state._type)); + } =20 newState( elementType, elementField, isNil ); =20 @@ -620,7 +627,6 @@ =20 if (state._attrs.contains( attrName )) { - // todo (dutta) need additional logic to determine the expecte= dSchemaType emitFieldError( event, XmlErrorCodes.XML_DUPLICATE_ATTRIBUTE, new Object[] { QNameHelper.pretty( attrName ) }, attrName, null, null, XmlValidationError.INCORRECT_ATTRIBU= TE, state._type ); @@ -632,10 +638,8 @@ =20 if (!state._canHaveAttrs) { - // BUGBUG: dead code? _canHaveAttrs is never set false - // KHK: cvc-complex-type.3 (.3.2.1?) - // todo (dutta) need additional logic to determine the expecte= dSchemaType - emitFieldError( event, "Can't have attributes", attrName, null= , null, + emitFieldError( event, XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY= _VALID$NO_WILDCARD, + new Object[] {QNameHelper.pretty( attrName )}, attrName, n= ull, null, XmlValidationError.INCORRECT_ATTRIBUTE, state._type); return; } @@ -651,7 +655,6 @@ =20 if (attrSchema.getUse() =3D=3D SchemaLocalAttribute.PROHIBITED) { - // todo (dutta) need additional logic to determine the exp= ectedSchemaType emitFieldError( event, XmlErrorCodes.ELEM_COMPLEX_TYPE_LOC= ALLY_VALID$PROHIBITED_ATTRIBUTE, new Object[] { QNameHelper.pretty( attrName ) } , attrName, null, null, XmlValidationError.INCORRECT_ATT= RIBUTE, state._type ); Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.ja= va URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/= xmlbeans/XmlErrorCodes.java?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java (or= iginal) +++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java Fri= Apr 1 18:39:18 2005 @@ -256,6 +256,12 @@ public static final String ELEM_LOCALLY_VALID$NIL_WITH_CONTENT =3D "cv= c-elt.3.2.1"; =20 /** + * cvc-elt.3.2.2: See clause 3.2.2 of + * <a href=3D"http://www.w3c.org/TR/xmlschema-1/#cvc-elt">XMLSchema St= ructures 1.0: Element Locally Valid (Element)</a> + */ + public static final String ELEM_LOCALLY_VALID$NIL_WITH_FIXED =3D "cvc-= elt.3.2.2"; + + /** * cvc-elt.4.1: See clause 4.1 of * <a href=3D"http://www.w3c.org/TR/xmlschema-1/#cvc-elt">XMLSchema St= ructures 1.0: Element Locally Valid (Element)</a> */ @@ -358,6 +364,12 @@ public static final String IDENTITY_CONSTRAINT_VALID$DUPLICATE_KEY =3D= "cvc-identity-constraint.4.2.2"; =20 /** + * cvc-identity-constraint.4.3: See clause 4.3 + * <a href=3D"http://www.w3.org/TR/xmlschema-1/#cvc-identity-constrain= t">XMLSchema Structures 1.0: Identity-constraint Satisfied</a> + */ + public static final String IDENTITY_CONSTRAINT_VALID$KEYREF_KEY_NOT_FO= UND =3D "cvc-identity-constraint.4.3"; + + /** * cvc-length-valid: See * <a href=3D"http://www.w3c.org/TR/xmlschema-2/#cvc-length-valid">XML= Schema Datatypes 1.0: Length Valid</a> */ @@ -1226,6 +1238,18 @@ * <a href=3D"http://www.w3c.org/TR/xmlschema-1/#e-props-correct">XMLS= chema Structures 1.0: Element Declaration Properties Correct</a> */ public static final String ELEM_PROPERTIES$CONSTRAINT_VALID =3D "e-pro= ps-correct.2"; + + /** + * e-props-correct.4: See clause 4 of + * <a href=3D"http://www.w3c.org/TR/xmlschema-1/#e-props-correct">XMLS= chema Structures 1.0: Element Declaration Properties Correct</a> + */ + public static final String ELEM_PROPERTIES$SUBSTITUTION_VALID =3D "e-p= rops-correct.4"; + + /** + * e-props-correct.4a: See clause 4 of + * <a href=3D"http://www.w3c.org/TR/xmlschema-1/#e-props-correct">XMLS= chema Structures 1.0: Element Declaration Properties Correct</a> + */ + public static final String ELEM_PROPERTIES$SUBSTITUTION_FINAL =3D "e-p= rops-correct.4a"; =20 /** * enumeration-required-notation: See Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properti= es URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/= xmlbeans/message.properties?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties (or= iginal) +++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties Fri= Apr 1 18:39:18 2005 @@ -136,6 +136,9 @@ cvc-elt.3.2.1 =3D \ Nil element cannot have element or text content =20 +cvc-elt.3.2.2 =3D \ +Nil element cannot have a fixed value constraint + cvc-elt.4.1 =3D \ Invalid xsi:type qname: ''{0}'' =20 @@ -189,6 +192,9 @@ cvc-identity-constraint.4.2.2 =3D \ Duplicate key ''{0}'' for key constraint ''{1}'' =20 +cvc-identity-constraint.4.3 =3D \ +Key ''{0}'' not found for keyref constraint ''{1}'' + cvc-length-valid =3D \ Length Valid =20 @@ -625,6 +631,12 @@ e-props-correct.2 =3D \ The ''{0}'' element {1} value ''{2}'' is not a valid value for ''{3}'' =20 +e-props-correct.4 =3D \ +Element ''{0}'' is not a valid substitution for element ''{1}'': its type = is not validly derived from element ''{1}''''s type + +e-props-correct.4a =3D \ +Element ''{0}'' is not a valid substitution for element ''{1}'' with final= =3D''{2}'' + enumeration-required-notation =3D \ enumeration facet value required for NOTATION =20 @@ -644,13 +656,13 @@ length valid restriction =20 maxExclusive-valid-restriction =3D \ -maxExclusive valid restriction +Invalid maxExclusive restriction: {0} =20 maxInclusive-maxExclusive =3D \ maxInclusive and maxExclusive =20 maxInclusive-valid-restriction =3D \ -maxInclusive valid restriction +Invalid maxInclusive restriction: {0} =20 maxLength-valid-restriction =3D \ Larger than prior maxLength. @@ -671,7 +683,7 @@ minExclusive < maxInclusive =20 minExclusive-valid-restriction =3D \ -minExclusive valid restriction +Invalid minExclusive restriction: {0} =20 minInclusive-less-than-equal-to-maxInclusive =3D \ minInclusive <=3D maxInclusive @@ -683,7 +695,7 @@ minInclusive and minExclusive =20 minInclusive-valid-restriction =3D \ -minInclusive valid restriction +Invalid minInclusive restriction: {0} =20 minLength-less-than-equal-to-maxLength =3D \ minLength <=3D maxLength Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckin= Tests.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/ch= eckin/XmlBeansCompCheckinTests.java?view=3Ddiff&r1=3D159750&r2=3D159751 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java (original) +++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java Fri Apr 1 18:39:18 2005 @@ -140,7 +140,7 @@ System.out.println(xErr); =20 if ((xErr.getErrorCode().compareTo("src-resolve") =3D= =3D 0) && - (xErr.getMessage().compareTo("type 'aType@http= ://baz' not found.") =3D=3D + (xErr.getMessage().compareTo("type 'bType@http= ://baz' not found.") =3D=3D 0)) psom_expError =3D true; } --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Mon Apr 04 17:14:13 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 23102 invoked from network); 4 Apr 2005 17:14:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2005 17:14:13 -0000 Received: (qmail 15352 invoked by uid 500); 4 Apr 2005 17:14:13 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 15332 invoked by uid 500); 4 Apr 2005 17:14:12 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 15318 invoked by uid 99); 4 Apr 2005 17:14:12 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 04 Apr 2005 10:14:12 -0700 Received: (qmail 23060 invoked by uid 65534); 4 Apr 2005 17:14:10 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Mon, 04 Apr 2005 17:14:10 -0000 Subject: svn commit: r160059 - xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/DomImpl.java To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cezar Date: Mon Apr 4 10:14:09 2005 New Revision: 160059 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D160059 Log: Yana Kadiyska. Reverting perf changes till all DRTs clear Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/DomImpl.java Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/DomImpl.j= ava URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlb= eans/impl/store/DomImpl.java?view=3Ddiff&r1=3D160058&r2=3D160059 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/DomImpl.java (o= riginal) +++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/DomImpl.java Mo= n Apr 4 10:14:09 2005 @@ -1308,12 +1308,54 @@ case DOCFRAG : case ATTR : { - if (n instanceof Xobj) + /* if (n instanceof Xobj) { Xobj node =3D (Xobj) n; if (node.isFirstChildPtrDomUsable()) - return (Xobj.NodeXobj) node._firstChild; + { + Dom myNode =3D (Xobj.NodeXobj) node._firstChild; + boolean nullFC =3D + node._firstChild =3D=3D null && + node._srcValue =3D=3D null && + node._charNodesValue =3D=3D null; + boolean null1FC =3D + node._firstChild !=3D null && + !node._firstChild.isAttr() && + node._srcValue =3D=3D null && + node._charNodesValue =3D=3D null; + String dump1 =3D null; + if ( myNode !=3D null ){ + dump1 =3D node._firstChild.new_cursor().xmlText(); + } + + + Cur c =3D n.tempCur(); + + c.next(); + + if ((fc =3D c.getCharNodes()) =3D=3D null) + { + c.moveToDom(n); + + if (c.toFirstChild()) + fc =3D c.getDom(); + } + + c.release(); + if (myNode !=3D fc) + { + XmlCursor c1 =3D node.new_cursor(); + throw new RuntimeException("DOMFC wrong result " + + c1.xmlText()+" B1 FC "+nullFC+" B2 FC "+null1FC+ + " exp "+fc+" got "+ dump1); + } + + break; + + + } } + */ =20 Cur c =3D n.tempCur(); =20 @@ -2614,13 +2656,23 @@ =20 //optimize for the 0 and 1 child case =20 - if (n instanceof Xobj) + /* if (n instanceof Xobj) { Xobj node =3D (Xobj) n; int count; - if ((count =3D node.getDomZeroOneChildren()) < 2) - return count; - } + if ((count =3D node.getDomZeroOneChildren()) < 2){ + long version =3D n.locale().version(); + XmlCursor c1 =3D node.new_cursor(); + String s =3D"" ;//=3D c1.xmlText(); + int real =3D n.locale().domLength(n); + if (count !=3D real) + throw new RuntimeException( "DOM ZEROONE short "+coun= t+ + " real "+ real+" "+s+" "+c1.xmlText()+ + " ver1"+version+" ver2 "+n.locale().version()); + return count; + } + + }*/ =20 return n.locale().domLength(n); } --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Wed Apr 06 03:20:41 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 23096 invoked from network); 6 Apr 2005 03:20:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Apr 2005 03:20:41 -0000 Received: (qmail 56707 invoked by uid 500); 6 Apr 2005 03:20:41 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 56672 invoked by uid 500); 6 Apr 2005 03:20:40 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 56659 invoked by uid 99); 6 Apr 2005 03:20:40 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 05 Apr 2005 20:20:40 -0700 Received: (qmail 23068 invoked by uid 65534); 6 Apr 2005 03:20:38 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Wed, 06 Apr 2005 03:20:38 -0000 Subject: svn commit: r160250 - in xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java xmlpublic/org/apache/xmlbeans/XmlBeans.java To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: radup Date: Tue Apr 5 20:20:36 2005 New Revision: 160250 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D160250 Log: Fixed a few NPEs. Made some changes to our URI resolver to better handle references from Sche= mas inside jar and zip files. Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParti= cleImpl.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeC= odePrinter.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporte= r=2Ejava xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem= aParticleImpl.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/SchemaParticleImpl.java?view=3Ddiff&r1=3D160249&r2=3D16= 0250 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParti= cleImpl.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParti= cleImpl.java Tue Apr 5 20:20:36 2005 @@ -123,6 +123,13 @@ =20 public SchemaParticle[] getParticleChildren() { + if (_particleChildren =3D=3D null) + { + assert _particleType !=3D SchemaParticle.ALL && + _particleType !=3D SchemaParticle.SEQUENCE && + _particleType !=3D SchemaParticle.CHOICE; + return null; + } SchemaParticle[] result =3D new SchemaParticle[_particleChildren.l= ength]; System.arraycopy(_particleChildren, 0, result, 0, _particleChildre= n=2Elength); return result; Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem= aTypeCodePrinter.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/SchemaTypeCodePrinter.java?view=3Ddiff&r1=3D160249&r2= =3D160250 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeC= odePrinter.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeC= odePrinter.java Tue Apr 5 20:20:36 2005 @@ -974,8 +974,11 @@ return "java.util.Calendar"; =20 case SchemaProperty.JAVA_ENUM: - SchemaType sType =3D sProp.javaBasedOnType().getBaseEnumTy= pe(); - return findJavaType(sType).replace('$', '.') + ".Enum"; + SchemaType sType =3D sProp.javaBasedOnType(); + if (sType.getSimpleVariety() =3D=3D SchemaType.UNION) + sType =3D sType.getUnionCommonBaseType(); + assert sType.getBaseEnumType() !=3D null; + return findJavaType(sType.getBaseEnumType()).replace('$', = '=2E') + ".Enum"; =20 case SchemaProperty.JAVA_OBJECT: return "java.lang.Object"; Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscI= mporter.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/schema/StscImporter.java?view=3Ddiff&r1=3D160249&r2=3D160250 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporte= r=2Ejava (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporte= r=2Ejava Tue Apr 5 20:20:36 2005 @@ -257,7 +257,7 @@ } =20 //workaround for Sun bug # 4723726 - private static URI resolve(URI base, String child) + public static URI resolve(URI base, String child) throws URISyntaxException { URI childUri =3D new URI(child); @@ -268,11 +268,26 @@ // URI is pointing at something nested inside a jar, we seem to ha= ve // to this ourselves to make sure that the nested jar url gets // resolved correctly - if (childUri.equals(ruri) && + if (childUri.equals(ruri) && !childUri.isAbsolute() && (base.getScheme().equals("jar") || base.getScheme().equals("zip"= ))) { String r =3D base.toString(); int lastslash =3D r.lastIndexOf('/'); r =3D r.substring(0,lastslash) + "/" + childUri; + // Sun's implementation of URI doesn't support references to t= he + // parent directory ("/..") in the part after "!/" so we have = to + // remove these ourselves + int slashDotDotIndex =3D r.lastIndexOf("/.."); + int exclPointSlashIndex =3D r.lastIndexOf("!/"); + while (slashDotDotIndex >=3D 0 && slashDotDotIndex > exclPoint= SlashIndex) + { + int prevSlashIndex =3D r.lastIndexOf("/", slashDotDotIndex= - 1); + if (prevSlashIndex >=3D exclPointSlashIndex) + { + String temp =3D r.substring(slashDotDotIndex + 3); + r =3D r.substring(0, prevSlashIndex).concat(temp); + } + slashDotDotIndex =3D r.lastIndexOf("/.."); + } return URI.create(r); } =20 Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/= xmlbeans/XmlBeans.java?view=3Ddiff&r1=3D160249&r2=3D160250 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (origina= l) +++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Tue Apr = 5 20:20:36 2005 @@ -530,7 +530,7 @@ */ public static SchemaTypeSystem compileXsd(XmlObject[] schemas, SchemaT= ypeLoader typepath, XmlOptions options) throws XmlException { - return compileXmlBeans(null, null, schemas, null, typepath!=3Dnull= ? typepath : getContextTypeLoader(), null, options); + return compileXmlBeans(null, null, schemas, null, typepath, null, = options); } =20 /** @@ -578,7 +578,7 @@ */ public static SchemaTypeSystem compileXsd(SchemaTypeSystem system, Xml= Object[] schemas, SchemaTypeLoader typepath, XmlOptions options) throws Xml= Exception { - return compileXmlBeans(null, system, schemas, null, typepath !=3D = null ? typepath : getContextTypeLoader(), null, options); + return compileXmlBeans(null, system, schemas, null, typepath, null= , options); } =20 /** @@ -611,7 +611,8 @@ * * <p>The optional SchemaTypeLoader argument will be * consulted for already-compiled schema types which may be linked - * while processing the given schemas.</p> + * while processing the given schemas. If not specified, the context + * typeloader (as returned by {@link #getContextTypeLoader}) will be u= sed.</p> * * <p>The optional {@link Filer} argument is used to create new binary= or source * files which are the product of the compilation. If the Filer is nu= ll, the @@ -646,7 +647,7 @@ =20 try { - return (SchemaTypeSystem)_compilationMethod.invoke(null, new O= bject[] { name, system, schemas, config, typepath, filer, options }); + return (SchemaTypeSystem)_compilationMethod.invoke(null, new O= bject[] { name, system, schemas, config, typepath !=3D null ? typepath : ge= tContextTypeLoader(), filer, options }); } catch (IllegalAccessException e) { --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Wed Apr 06 22:50:14 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 46325 invoked from network); 6 Apr 2005 22:50:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Apr 2005 22:50:14 -0000 Received: (qmail 87067 invoked by uid 500); 6 Apr 2005 22:50:14 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 87017 invoked by uid 500); 6 Apr 2005 22:50:14 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 86988 invoked by uid 99); 6 Apr 2005 22:50:13 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 06 Apr 2005 15:50:13 -0700 Received: (qmail 46306 invoked by uid 65534); 6 Apr 2005 22:50:12 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Wed, 06 Apr 2005 22:50:12 -0000 Subject: svn commit: r160341 - in xmlbeans/trunk/src: common/org/apache/xmlbeans/impl/common/NameUtil.java xmlpublic/org/apache/xmlbeans/XmlBeans.java To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: radup Date: Wed Apr 6 15:50:10 2005 New Revision: 160341 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D160341 Log: Two small fixes. Modified: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/NameUtil.java xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Modified: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/NameUti= l=2Ejava URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/common/org/apache/xml= beans/impl/common/NameUtil.java?view=3Ddiff&r1=3D160340&r2=3D160341 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/NameUtil.java= (original) +++ xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/NameUtil.java= Wed Apr 6 15:50:10 2005 @@ -403,7 +403,10 @@ StringBuffer buf =3D new StringBuffer(name); for (int i =3D 0; i < name.length(); i++) { - if (!Character.isJavaIdentifierPart(buf.charAt(i))) + // We need to also make sure that our package names don't cont= ain the + // "$" character in them, which, although a valid Java identif= ier part, + // would create confusion when trying to generate fully-qualif= ied names + if (!Character.isJavaIdentifierPart(buf.charAt(i)) || '$' =3D= =3D buf.charAt(i)) buf.setCharAt(i, '_'); } if (buf.length() =3D=3D 0 || !Character.isJavaIdentifierStart(buf.= charAt(0))) Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/= xmlbeans/XmlBeans.java?view=3Ddiff&r1=3D160340&r2=3D160341 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (origina= l) +++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Wed Apr = 6 15:50:10 2005 @@ -642,9 +642,6 @@ */ public static SchemaTypeSystem compileXmlBeans(String name, SchemaType= System system, XmlObject[] schemas, BindingConfig config, SchemaTypeLoader = typepath, Filer filer, XmlOptions options) throws XmlException { - if (typepath =3D=3D null) - throw new IllegalArgumentException("Must supply a SchemaTypeLo= ader for compiletime linking"); - try { return (SchemaTypeSystem)_compilationMethod.invoke(null, new O= bject[] { name, system, schemas, config, typepath !=3D null ? typepath : ge= tContextTypeLoader(), filer, options }); --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Wed Apr 06 23:52:42 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 54405 invoked from network); 6 Apr 2005 23:52:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Apr 2005 23:52:42 -0000 Received: (qmail 37904 invoked by uid 500); 6 Apr 2005 23:52:42 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 37868 invoked by uid 500); 6 Apr 2005 23:52:42 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 37854 invoked by uid 99); 6 Apr 2005 23:52:42 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 06 Apr 2005 16:52:41 -0700 Received: (qmail 54400 invoked by uid 65534); 6 Apr 2005 23:52:40 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Wed, 06 Apr 2005 23:52:40 -0000 Subject: svn commit: r160344 - in xmlbeans/trunk/test: cases/xbean/scomp/element/NillTest.xsd src/compile/scomp/checkin/XmlBeansCompCheckinTests.java src/scomp/elements/detailed/GlobalEltNillable.java src/scomp/elements/detailed/NillTest.java src/scomp/idConstraint/detailed/KeyKeyref.java To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cezar Date: Wed Apr 6 16:52:38 2005 New Revision: 160344 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D160344 Log: Contributed By Rajiv Balachandran - Changed/Added tests for Nillable funct= ionality and modified checkintest to reflect revision 160341 Modified: xmlbeans/trunk/test/cases/xbean/scomp/element/NillTest.xsd xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java xmlbeans/trunk/test/src/scomp/elements/detailed/GlobalEltNillable.java xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java xmlbeans/trunk/test/src/scomp/idConstraint/detailed/KeyKeyref.java Modified: xmlbeans/trunk/test/cases/xbean/scomp/element/NillTest.xsd URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/scomp/el= ement/NillTest.xsd?view=3Ddiff&r1=3D160343&r2=3D160344 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/cases/xbean/scomp/element/NillTest.xsd (original) +++ xmlbeans/trunk/test/cases/xbean/scomp/element/NillTest.xsd Wed Apr 6 1= 6:52:38 2005 @@ -9,6 +9,7 @@ <xs:sequence> <xs:element name=3D"firstName" type=3D"xs:string" minOccurs=3D= "0"/> <xs:element name=3D"lastName" type=3D"xs:string" minOccurs=3D"= 0"/> + <xs:element name=3D"LocalNillableElem" type=3D"xs:string" nill= able=3D"true"/> <xs:element name=3D"address" type=3D"AddressInfo" minOccurs=3D= "0"/> </xs:sequence> </xs:complexType> @@ -28,6 +29,9 @@ </xs:element> =20 <xs:element name=3D"GlobalEltNotNillable" type=3D"xs:string"/> + <xs:element name=3D"GlobalEltNillable" type=3D"xs:string" nillable=3D"= true"/> + <xs:element name=3D"GlobalEltDefault" type=3D"xs:integer" default=3D"1= 0"/> + <xs:element name=3D"GlobalEltFixed" type=3D"xs:integer" fixed=3D"7" /> =20 =20 </xs:schema> Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckin= Tests.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/ch= eckin/XmlBeansCompCheckinTests.java?view=3Ddiff&r1=3D160343&r2=3D160344 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java (original) +++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.= java Wed Apr 6 16:52:38 2005 @@ -292,9 +292,8 @@ System.err.println(iaEx.getMessage()); } =20 - if (!iArgExThrown) - throw new Exception("All null values did not throw Illegal " + - "Argument Exception"); + // svn revision 160341. SchemaTypeLoader is not expected to non nu= ll any more. All params can be null + assertFalse(iArgExThrown); =20 iArgExThrown =3D false; try { @@ -306,9 +305,8 @@ System.err.println(iaEx.getMessage()); } =20 - if (!iArgExThrown) - throw new Exception("XSD[] and null values did not throw Illeg= al " + - "Argument Exception"); + // svn revision 160341. SchemaTypeLoader is not expected to non nu= ll any more + assertFalse(iArgExThrown); =20 } =20 Modified: xmlbeans/trunk/test/src/scomp/elements/detailed/GlobalEltNillable= .java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/scomp/elements/d= etailed/GlobalEltNillable.java?view=3Ddiff&r1=3D160343&r2=3D160344 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/scomp/elements/detailed/GlobalEltNillable.java = (original) +++ xmlbeans/trunk/test/src/scomp/elements/detailed/GlobalEltNillable.java = Wed Apr 6 16:52:38 2005 @@ -19,6 +19,7 @@ import xbean.scomp.element.globalEltNillable.*; import org.apache.xmlbeans.impl.values.XmlValueNotNillableException; import org.apache.xmlbeans.XmlErrorCodes; +import org.apache.xmlbeans.XmlOptions; =20 /** * @@ -55,8 +56,13 @@ * @throws Exception */ public void testNotNillable() throws Exception { + + // XmlValueNotNillableException should be thrown only when validat= eOnSet property is set + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + GlobalEltNotNillableDocument testElt =3D GlobalEltNotNillableDocum= ent - .Factory.newInstance(); + .Factory.newInstance(options); try { testElt.setNil(); fail("Expected XmlValueNotNillableException"); @@ -93,12 +99,13 @@ GlobalEltNillableFixedDocument testElt =3D GlobalEltNillableFixedD= ocument .Factory.parse("<GlobalEltNillableFixed" + " xmlns=3D\"http://xbean/scomp/element/GlobalEltNillable= \"" + - " xsi:nillable=3D\"true\"" + + " xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instanc= e\"" + + " xsi:nil=3D\"true\"" + "/>"); - assertTrue(!testElt.validate(validateOptions)); + assertFalse(testElt.validate(validateOptions)); assertEquals(1, errorList.size()); showErrors(); - String[] errExpected =3D new String[]{"cvc-elt3.3.4"}; + String[] errExpected =3D new String[]{XmlErrorCodes.ELEM_LO= CALLY_VALID$NIL_WITH_FIXED}; assertTrue(compareErrorCodes(errExpected)); =20 =20 Modified: xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/scomp/elements/d= etailed/NillTest.java?view=3Ddiff&r1=3D160343&r2=3D160344 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java (original) +++ xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java Wed Apr = 6 16:52:38 2005 @@ -15,11 +15,11 @@ package scomp.elements.detailed; =20 import scomp.common.BaseCase; -import xbean.scomp.element.nillTest.Contact; -import xbean.scomp.element.nillTest.AddressInfo; -import xbean.scomp.element.nillTest.CityNameDocument; -import xbean.scomp.element.nillTest.GlobalEltNotNillableDocument; +import xbean.scomp.element.nillTest.*; import org.apache.xmlbeans.impl.values.XmlValueNotNillableException; +import org.apache.xmlbeans.XmlOptions; + +import java.math.BigInteger; =20 =20 /** @@ -36,33 +36,183 @@ * XXX attribute/element and if the container is an * element, will also add the "xsi:nil" attribute. */ - public void testNillable() { - Contact contact =3D Contact.Factory.newInstance(); + // for all nillable tests, the validation falls thro only if the Valid= ateOnSet option is turned on + public void testNotNillableLocalElem() { + + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // local element, not nillable. If setXXX is set to null & validat= eOnSet is true, it should throw XmlValueNotNillableException + Contact contact =3D Contact.Factory.newInstance(options); + try{ + contact.setFirstName(null); + fail("XmlValueNotNillableException Expected here"); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + } + + // with validate turned off, this should to thro + Contact contactWithValidateOff =3D Contact.Factory.newInstance(opt= ions); + try{ + contactWithValidateOff.setFirstName(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException NOT Expected here"); + } + assertEquals("<firstName " + + "xsi:nil=3D\"true\" " + + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", + contact.xmlText()); + + } + + public void testNotNillableGlobalElem() { + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // global element, not nillable. If setXXX is set to null & valida= teOnSet is true, it should throw XmlValueNotNillableException + CityNameDocument cityName =3D CityNameDocument.Factory.newInstance= (options); + try{ + cityName.setCityName(null); + fail("XmlValueNotNillableException Expected here"); + } + catch (XmlValueNotNillableException e) { + } + + // with validate turned off, this should to thro + CityNameDocument cityNameWithValidateOff =3D CityNameDocument.Fact= ory.newInstance(); + try{ + cityNameWithValidateOff.setCityName(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException NOT Expected here"); + } + + assertEquals("<nil:cityName " + + "xsi:nil=3D\"true\" " + + "xmlns:nil=3D\"http://xbean/scomp/element/NillTest\" " + + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", + cityNameWithValidateOff.xmlText()); + } + + public void testNillableGlobalElement() + { + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // global element, nillable. If setXXX is set to null & validateOn= Set is true, it should NOT throw XmlValueNotNillableException + GlobalEltNillableDocument testElt =3D GlobalEltNillableDocument + .Factory.newInstance(options); + try{ + testElt.setGlobalEltNillable(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException Not Expected here"); + } + assertEquals("<nil:GlobalEltNillable " + + "xsi:nil=3D\"true\" " + + "xmlns:nil=3D\"http://xbean/scomp/element/NillTest\" " + + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", + testElt.xmlText()); =20 - // if the first name is null, xmlbeans doest not thrown any excepti= ons... - contact.setFirstName(null); - assertEquals("<firstName " + + // without the validateOnSet - no exception in this case either + GlobalEltNillableDocument testEltWithValidateOff =3D GlobalEltNill= ableDocument + .Factory.newInstance(); + try{ + testEltWithValidateOff.setGlobalEltNillable(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException Not Expected here"); + } + assertEquals("<nil:GlobalEltNillable " + + "xsi:nil=3D\"true\" " + + "xmlns:nil=3D\"http://xbean/scomp/element/NillTest\" " + + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", + testElt.xmlText()); + + + } + + public void testNillableLocalElement() + { + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // global element, nillable. If setXXX is set to null & validateOn= Set is true, it should NOT throw XmlValueNotNillableException + Contact contact =3D Contact + .Factory.newInstance(options); + try{ + contact.setLocalNillableElem(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException Not Expected here"); + } + assertEquals("<LocalNillableElem " + "xsi:nil=3D\"true\" " + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", contact.xmlText()); - GlobalEltNotNillableDocument testElt =3D GlobalEltNotNillableDocum= ent + + // without the validateOnSet - no exception in this case either + Contact contactWithValidationOff =3D Contact .Factory.newInstance(); - testElt.setGlobalEltNotNillable(null); + try{ + contactWithValidationOff.setLocalNillableElem(null); + } + catch (XmlValueNotNillableException e) { + e.printStackTrace(); + fail("XmlValueNotNillableException Not Expected here"); + } + assertEquals("<LocalNillableElem " + + "xsi:nil=3D\"true\" " + + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", + contactWithValidationOff.xmlText()); + + + } =20 - CityNameDocument doc =3D CityNameDocument.Factory.newInstance(); - try { - doc.setCityName(null); - fail("Expected XmlValueNotNillableException"); + public void testDefaultValElement() + { + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // default value element, not nillable. If setXXX is set to null &= validateOnSet is true, it should + // throw XmlValueNotNillableException and validation should fail + GlobalEltDefaultDocument elt =3D GlobalEltDefaultDocument + .Factory.newInstance(options); + try{ + elt.setGlobalEltDefault(null); + System.out.println("Elt Text:" + elt.xmlText()); + assertFalse(elt.validate()); + fail("XmlValueNotNillableException Expected here"); + } + catch (XmlValueNotNillableException e) { + } + } + + public void testNotNillableFixedValueElement() + { + XmlOptions options =3D new XmlOptions(); + options.setValidateOnSet(); + + // fixed value element, not nillable. If setXXX is set to null & v= alidateOnSet is true, it should + // throw XmlValueNotNillableException and validation should fail + GlobalEltFixedDocument elt =3D GlobalEltFixedDocument + .Factory.newInstance(options); + try{ + elt.setGlobalEltFixed(null); + System.out.println("Elt Text:" + elt.xmlText()); + assertFalse(elt.validate()); + fail("XmlValueNotNillableException Expected here"); } catch (XmlValueNotNillableException e) { + e.printStackTrace(); } - testElt.setGlobalEltNotNillable(null); - AddressInfo address =3D AddressInfo.Factory.newInstance(); - //this can be null - address.setGlobalEltNotNillable(null); - // ...whereas this optional field cannot be null - //???throws an exception: - //likely due to the fact that it is a facet. - address.setCityName(null); } + } Modified: xmlbeans/trunk/test/src/scomp/idConstraint/detailed/KeyKeyref.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/scomp/idConstrai= nt/detailed/KeyKeyref.java?view=3Ddiff&r1=3D160343&r2=3D160344 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/scomp/idConstraint/detailed/KeyKeyref.java (ori= ginal) +++ xmlbeans/trunk/test/src/scomp/idConstraint/detailed/KeyKeyref.java Wed = Apr 6 16:52:38 2005 @@ -241,7 +241,8 @@ assertTrue(!doc.validate(validateOptions)); showErrors(); String[] errExpected =3D new String[]{ - XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_KEY + XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_KEY, + XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$KEYREF_KEY_NOT_FOUND }; assertTrue(compareErrorCodes(errExpected)); =20 --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Fri Apr 08 00:48:26 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 66381 invoked from network); 8 Apr 2005 00:48:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Apr 2005 00:48:26 -0000 Received: (qmail 77550 invoked by uid 500); 8 Apr 2005 00:48:26 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 77501 invoked by uid 500); 8 Apr 2005 00:48:25 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 77487 invoked by uid 99); 8 Apr 2005 00:48:25 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 07 Apr 2005 17:48:24 -0700 Received: (qmail 66376 invoked by uid 65534); 8 Apr 2005 00:48:23 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 08 Apr 2005 00:48:23 -0000 Subject: svn commit: r160500 - in xmlbeans/trunk: src/typeimpl/org/apache/xmlbeans/impl/values/JavaIntHolder.java src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java test/src/scomp/elements/detailed/NillTest.java To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: radup Date: Thu Apr 7 17:48:22 2005 New Revision: 160500 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D160500 Log: Fixed nillable validation for local elements when validateOnSet() is true. Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/JavaIntHold= er.java xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBa= se.java xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/JavaI= ntHolder.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/values/JavaIntHolder.java?view=3Ddiff&r1=3D160499&r2=3D160500 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/JavaIntHold= er.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/JavaIntHold= er.java Thu Apr 7 17:48:22 2005 @@ -47,7 +47,7 @@ _value =3D 0; } // numerics: fractional - public BigDecimal bigDecimalValue() { check_dated(); return new BigDec= imal(_value); } + public BigDecimal bigDecimalValue() { check_dated(); return new BigDec= imal((double) _value); } public BigInteger bigIntegerValue() { check_dated(); return BigInteger= .valueOf(_value); } public long longValue() { check_dated(); return _value; } public int intValue() { check_dated(); return _value; } Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlOb= jectBase.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/x= mlbeans/impl/values/XmlObjectBase.java?view=3Ddiff&r1=3D160499&r2=3D160500 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBa= se.java (original) +++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBa= se.java Thu Apr 7 17:48:22 2005 @@ -540,6 +540,7 @@ prop.hasNillable() =3D=3D SchemaProperty.VARIABLE) return; =20 + _flags &=3D ~FLAGS_ELEMENT; _flags |=3D (prop.hasDefault() =3D=3D SchemaProperty.NEVER ? 0 : TypeStore= .HASDEFAULT) | (prop.hasFixed() =3D=3D SchemaProperty.NEVER ? 0 : TypeStore.F= IXED) | Modified: xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/scomp/elements/d= etailed/NillTest.java?view=3Ddiff&r1=3D160499&r2=3D160500 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java (original) +++ xmlbeans/trunk/test/src/scomp/elements/detailed/NillTest.java Thu Apr = 7 17:48:22 2005 @@ -53,7 +53,7 @@ } =20 // with validate turned off, this should to thro - Contact contactWithValidateOff =3D Contact.Factory.newInstance(opt= ions); + Contact contactWithValidateOff =3D Contact.Factory.newInstance(); try{ contactWithValidateOff.setFirstName(null); } @@ -64,7 +64,7 @@ assertEquals("<firstName " + "xsi:nil=3D\"true\" " + "xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\"/= >", - contact.xmlText()); + contactWithValidateOff.xmlText()); =20 } =20 --------------------------------------------------------------------- To unsubscribe, e-mail: johnsonbrian@example.com For additional commands, e-mail: johnsonbrian@example.com From commitsjohnsonbrian@example.com Fri Apr 08 21:14:50 2005 Return-Path: <commitsjohnsonbrian@example.com> Delivered-To: johnsonbrian@example.com Received: (qmail 15502 invoked from network); 8 Apr 2005 21:14:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Apr 2005 21:14:50 -0000 Received: (qmail 69591 invoked by uid 500); 8 Apr 2005 21:14:49 -0000 Delivered-To: johnsonbrian@example.com Received: (qmail 69554 invoked by uid 500); 8 Apr 2005 21:14:48 -0000 Mailing-List: contact johnsonbrian@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:johnsonbrian@example.com> List-Help: <mailto:johnsonbrian@example.com> List-Unsubscribe: <mailto:johnsonbrian@example.com> List-Subscribe: <mailto:johnsonbrian@example.com> Reply-To: johnsonbrian@example.com Delivered-To: mailing list johnsonbrian@example.com Received: (qmail 69541 invoked by uid 99); 8 Apr 2005 21:14:48 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 08 Apr 2005 14:14:46 -0700 Received: (qmail 15458 invoked by uid 65534); 8 Apr 2005 21:14:45 -0000 Message-ID: <johnsonbrian@example.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 08 Apr 2005 21:14:45 -0000 Subject: svn commit: r160610 [3/3] - in xmlbeans/site: build/site/docs/2.0.0/guide/ build/site/documentation/ build/site/samples/ build/site/sourceAndBinaries/ src/documentation/content/docs/2.0.0/guide/ src/documentation/content/xdocs/documentation/ src/documentation/content/xdocs/sourceAndBinaries/ To: johnsonbrian@example.com From: johnsonbrian@example.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: xmlbeans/site/src/documentation/content/docs/2.0.0/guide/conSelec= tingXMLwithXQueryPathXPath.html URL: http://svn.apache.org/viewcvs/xmlbeans/site/src/documentation/content/= docs/2.0.0/guide/conSelectingXMLwithXQueryPathXPath.html?view=3Ddiff&r1=3D1= 60609&r2=3D160610 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- xmlbeans/site/src/documentation/content/docs/2.0.0/guide/conSelectingXM= LwithXQueryPathXPath.html (original) +++ xmlbeans/site/src/documentation/content/docs/2.0.0/guide/conSelectingXM= LwithXQueryPathXPath.html Fri Apr 8 14:14:42 2005 @@ -1,270 +1 @@ -<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN"> - -<!-- Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli= ed. - See the License for the specific language governing permissions and - limitations under the License. --> -<html> -<head> -<!-- InstanceBeginEditable name=3D"doctitle" --> -<title>Selecting XML with XQuery and XPath</title> -<!-- InstanceEndEditable --> -<!--(Meta)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> - -<meta http-equiv=3DContent-Type content=3D"text/html; charset=3D$CHARSET;"> - - -<!-- InstanceBeginEditable name=3D"metatags" --> - -<meta content=3D"your name" name=3D"author"> -<meta content=3D"A description of the topic contents." name=3D"description= "> -<meta content=3D"keywords to help in searches" name=3D"keywords"> -<meta content=3D"10/25/02" name=3D"date last modified"> -<!-- InstanceEndEditable --> - -<!--(Links)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> -<!-- InstanceBeginEditable name=3D"head" --> -<link href=3D"../xmlbeans.css" rel=3D"stylesheet" type=3D"text/css"> -<!-- InstanceEndEditable --> -<link href=3D"../xmlbeans.css" rel=3D"stylesheet" type=3D"text/css"> -<a href=3D"../../../core/index.html" id=3D"index"></a> -<script language=3D"JavaScript" src=3D"../../../core/topicInfo.js"></scrip= t> -<script language=3D"JavaScript" src=3D"../../../core/CookieClass.js"></scr= ipt> -<script language=3D"JavaScript" src=3D"../../../core/displayContent.js"></= script> -</head> - -<!--(Body)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> -<body> -<script language=3D"JavaScript"> - -</script> -<!-- InstanceBeginEditable name=3D"body" --> -<h1> Selecting XML with XQuery and XPath</h1> -<div id=3D"topictext"> - <p>You can use XQuery and XPath to retrieve specific pieces of XML as yo= u might - retrieve data from a database. XQuery and XPath provide a syntax for s= pecifying - which elements and attributes you're interested in. The XMLBeans API p= rovides - two methods for executing XQuery and XPath expressions, and two differ= ing - ways to use them. The methods are <span class=3D"langinline">selectPat= h</span> - and <span class=3D"langinline">execQuery</span>, and you can call them= from - <a href=3D"../reference/org/apache/xmlbeans/XmlObject.html"><span clas= s=3D"langinline">XmlObject</span></a> - (or an object inheriting from it) or <a href=3D"../reference/org/apach= e/xmlbeans/XmlCursor.html"><span class=3D"langinline">XmlCursor</span></a>. - The results for the methods differ somewhat. </p> - <h2>Using the selectPath Method</h2> -</div> -<div> - <p>The <span class=3D"langinline">selectPath</span> method is the most e= fficient - way to execute XPath expressions. The <span class=3D"langinline">selec= tPath</span> - method is optimized for XPath. When you use XPath with the <span class= =3D"langinline">selectPath</span> - method, the value returned is an array of values from the <em>current = document</em>. - In contrast, when you use <span class=3D"langinline">execQuery</span>,= the value - returned is a <em>new document</em>.</p> - <h3>Calling from XmlObject</h3> - <p>When called from <span class=3D"langinline">XmlObject</span> (or a ty= pe that - inherits from it), this method returns an array of objects. If the exp= ression - is executed against types generated from schema, then the type for the= returned - array is one of the Java types corresponding to the schema. </p> - <p>For example, imagine you have the following XML containing employee i= nformation. - You've compiled the schema describing this XML and the types generated= from - schema are available to your code.</p> -<pre> -&lt;xq:employees xmlns:xq=3D&quot;http://openuri.org/selectPath&quot;&gt; - &lt;xq:employee&gt; - &lt;xq:name&gt;Fred Jones&lt;/xq:name&gt; - &lt;xq:address location=3D&quot;home&quot;&gt; - &lt;xq:street&gt;900 Aurora Ave.&lt;/xq:street&gt; - &lt;xq:city&gt;Seattle&lt;/xq:city&gt; - &lt;xq:state&gt;WA&lt;/xq:state&gt; - &lt;xq:zip&gt;98115&lt;/xq:zip&gt; - &lt;/xq:address&gt; - &lt;xq:address location=3D&quot;work&quot;&gt; - &lt;xq:street&gt;2011 152nd Avenue NE&lt;/xq:street&gt; - &lt;xq:city&gt;Redmond&lt;/xq:city&gt; - &lt;xq:state&gt;WA&lt;/xq:state&gt; - &lt;xq:zip&gt;98052&lt;/xq:zip&gt; - &lt;/xq:address&gt; - &lt;xq:phone location=3D&quot;work&quot;&gt;(217)429-5357&lt;/xq:p= hone&gt; - &lt;xq:phone location=3D&quot;home&quot;&gt;(217)429-5357&lt;/xq:p= hone&gt; - &lt;xq:phone location=3D&quot;mobile&quot;&gt;(217)429-5357&lt;/xq= :phone&gt; - &lt;/xq:employee&gt; -&lt;/xq:employees&gt; -</pre> - If you wanted to find the phone numbers whose area code was 206, you cou= ld capture - the XPath expression in this way: - <pre> -String queryExpression =3D - &quot;declare namespace xq=3D'http://openuri.org/selectPath'&quot; + - &quot;$this/xq:employees/xq:employee/xq:phone[contains(., '(206)')]&qu= ot; -</pre> - <p>Notice in the query expression that the variable <span class=3D"langi= nline">$this</span> - represents the current context node (the <span class=3D"langinline">Xm= lObject</span> - that you are querying from). In this example you are querying from the= document - level <span class=3D"langinline">XmlObject</span>.</p> - <p>You could then print the results with code such as the following:</p> - <pre> -/* - * Retrieve the matching phone elements and assign the results to the corr= esponding - * generated type. - */ -PhoneType[] phones =3D (PhoneType[])empDoc.selectPath(queryExpression); -/* - * Loop through the results, printing the value of the phone element. - */ -for (int i =3D 0; i < phones.length; i++) -{ - System.out.println(phones[i].stringValue()); -} </pre> - - <h3>Calling from XmlCursor</h3> - <p>When called from an <span class=3D"langinline">XmlCursor</span> insta= nce, the - <span class=3D"langinline">selectPath</span> method retrieves a list o= f selections, - or locations in the XML. The selections are remembered by the cursor i= nstance. - You can use methods such as <span class=3D"langinline">toNextSelection= </span> - to navigate among them.</p> - <div> - <p>The <span class=3D"langinline">selectPath</span> method takes an XP= ath expression. - If the expression returns any results, each of those results is adde= d as - a selection to the cursor's list of selections. You can move through= these - selections in the way you might use <span class=3D"langinline">java.= util.Iterator</span> - methods to move through a collection.</p> - <p> For example, for a path such as <span class=3D"langinline">$this/e= mployees/employee</span>, - the results would include a selection for each employee element foun= d by - the expression. Note that the variable <span class=3D"langinline">$t= his</span> - is always bound to the current context node, which in this example i= s the - document. After calling the <span class=3D"langinline">selectPath</s= pan> method, - you would use various &quot;selection&quot;-related methods to work = with - the results. These methods include:</p> - </div> - <ul> - <li> - <div><span class=3D"langinline">getSelectionCount() </span>to retrie= ve the - number of selections resulting from the query.</div> - </li> - <li> - <div> <span class=3D"langinline">toNextSelection()</span> to move th= e cursor - to the next selection in the list (such as to the one pointing at = the - next employee element found).</div> - </li> - <li> - <div> <span class=3D"langinline">toSelection(int)</span> to move the= cursor - to the selection at the specified index (such as to the third empl= oyee - element in the selection).</div> - </li> - <li> - <div> <span class=3D"langinline">hasNextSelection()</span> to find o= ut if - there are more selections after the cursor's current position.</di= v> - </li> - <li> - <div><span class=3D"langinline"> clearSelections()</span> clears the= selections - from the current cursor. This doesn't modify the document (in othe= r words, - it doesn't delete the selected XML); it merely clears the selectio= n list - so that the cursor is no longer keeping track of those positions.<= /div> - </li> - </ul> - <div> - <p>The following example shows how you might use <span class=3D"langin= line">selectPath</span>, - in combination with the <span class=3D"langinline">push</span> and <= span class=3D"langinline">pop</span> - methods, to maneuver through XML, retrieving specific values. </p> - <pre> -public void printZipsAndWorkPhones(XmlObject xml) -{ - // Declare the namespace that will be used. - String xqNamespace =3D - &quot;declare namespace xq=3D'http://openuri.org/selectPath'&quot;; - - // Insert a cursor and move it to the first element. - XmlCursor cursor =3D xml.newCursor(); - cursor.toFirstChild(); - /* - * Save the cursor's current location by pushing it - * onto a stack of saved locations. - */ - cursor.push(); - // Query for zip elements. - cursor.selectPath(xqNamespace + &quot;$this//xq:zip&quot;); - /* - * Loop through the list of selections, getting the value of - * each element. - */ - while (cursor.toNextSelection()) - { - System.out.println(cursor.getTextValue()); - } - // Pop the saved location off the stack. - cursor.pop(); - // Query again from the top, this time for work phone numbers. - cursor.selectPath(xqNamespace + &quot;$this//xq:phone[@location=3D'wor= k']&quot;); - /* - * Move the cursor to the first selection, them print that element's - * value. - */ - cursor.toNextSelection(); - System.out.println(cursor.getTextValue()); - // Dispose of the cursor. - cursor.dispose(); -} -</pre> - <p>Using selections is somewhat like tracking the locations of multipl= e cursors - with a single cursor. This becomes especially clear when you remove = the - XML associated with a selection. When you do so the selection itself= remains - at the location where the removed XML was, but now the selection's l= ocation - is immediately before the XML that was after the XML you removed. In= other - words, removing XML created a kind of vacuum that was filled by the = XML - after it, which shifted up into the space &#8212; up into position i= mmediately - after the selection location. This is exactly the same as if the sel= ection - had been another cursor.</p> - <p>Finally, when using selections keep in mind that the list of select= ions - is in a sense &quot;live&quot;. The cursor you're working with is ke= eping - track of the selections in the list. In other words, be sure to call= the - <span class=3D"langinline">clearSelections</span> method when you're= finished - with the selections, just as you should call the <span class=3D"lang= inline">XmlCursor.dispose()</span> - method when you're finished using the cursor.</p> - </div> - <h2>Using the execQuery Method</h2> - <p>Use the <span class=3D"langinline">execQuery</span> method to execute= XQuery - expressions that are more sophisticated than paths. These expressions = include - more sophisticated loops and FLWR (For, Let, Where, and Results) expre= ssions. - </p> - <p class=3D"notepara"><strong>Note:</strong> Be sure to see the simpleEx= pressions - sample in the SamplesApp application for a sampling of XQuery expressi= ons - in use.</p> - <h3>Calling from XmlObject</h3> - <p>Unlike <span class=3D"langinline">selectPath</span>, calling <span cl= ass=3D"langinline">execQuery</span> - from an <span class=3D"langinline">XmlObject</span> instance will retu= rn an - <span class=3D"langinline">XmlObject</span> array. If the <span class= =3D"langinline">XmlObject</span> - instances resulting from the XQuery match a recognized XMLBeans type (= the - namespace and top level element name match up with an XMLBeans type) t= hen - the <span class=3D"langinline">XmlObject</span> will be typed; otherwi= se the - <span class=3D"langinline">XmlObject</span> will be untyped.</p> - <h3>Calling from XmlCursor</h3> -</div> - -<div> - <p>Calling <span class=3D"langinline">execQuery</span> from an <span cla= ss=3D"langinline">XmlCursor</span> - instance returns a new <span class=3D"langinline">XmlCursor</span> ins= tance. - The cursor returned is positioned at the beginning of a new xml docume= nt representing - the query results, and you can use it to move through the results, cur= sor-style - (for more information, see <a href=3D"conNavigatingXMLwithCursors.html= ">Navigating - XML with Cursors</a>). If the document resulting from the query execut= ion - represents a recognized XMLBeans type (the namespace and top level ele= ment - name match up with an XMLBeans type) then the document resulting from = the - xquery will have that Java type; otherwise the resulting document will= be - untyped.</p> - <h2>Related Topics</h2> -</div> -<p><a href=3D"conGettingStartedwithXMLBeans.html">Getting Started with XML= Beans</a></p> -<!-- InstanceEndEditable --> -<script language=3D"JavaScript"> - -</script> -</body> -</html> +<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN"> <!-- Copyright= 2004 The Apache Software Foundation Licensed under the Apache Licens= e, Version 2.0 (the "License"); you may not use this file except in co= mpliance with the License. You may obtain a copy of the License at = http://www.apache.org/licenses/LICENSE-2.0 Unless required by = applicable law or agreed to in writing, software distributed under the= License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CON= DITIONS OF ANY KIND, either express or implied. See the License for th= e specific language governing permissions and limitations under the Li= cense. --> <html> <head> <!-- InstanceBeginEditable name=3D"doctitle" --> <= title>Selecting XML with XQuery and XPath</title> <!-- InstanceEndEditable = --> <!--(Meta)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> <meta http-equiv=3DContent-Type= content=3D"text/html; charset=3D$CHARSET;"> <!-- InstanceBeginEditable n= ame=3D"metatags" --> <meta content=3D"your name" name=3D"author"> <meta co= ntent=3D"A description of the topic contents." name=3D"description"> <meta = content=3D"keywords to help in searches" name=3D"keywords"> <meta content= =3D"10/25/02" name=3D"date last modified"> <!-- InstanceEndEditable --> <!= --(Links)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> <!-- InstanceBeginEditable name=3D"head" = --> <link href=3D"../xmlbeans.css" rel=3D"stylesheet" type=3D"text/css"> <!= -- InstanceEndEditable --> <link href=3D"../xmlbeans.css" rel=3D"stylesheet= " type=3D"text/css"> <a href=3D"../../../core/index.html" id=3D"index"></a>= <script language=3D"JavaScript" src=3D"../../../core/topicInfo.js"></scrip= t> <script language=3D"JavaScript" src=3D"../../../core/CookieClass.js"></s= cript> <script language=3D"JavaScript" src=3D"../../../core/displayContent.= js"></script> </head> <!--(Body)=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> <body> <script= language=3D"JavaScript"> </script> <!-- InstanceBeginEditable name=3D"bod= y" --> <h1> Selecting XML with XQuery and XPath</h1> <div id=3D"topictext">= <p>You can use XQuery and XPath to retrieve specific pieces of XML as = you might retrieve data from a database. XQuery and XPath provide a= syntax for specifying which elements and attributes you're interes= ted in. The XMLBeans API provides two methods for executing XQuery = and XPath expressions, and two differing ways to use them. The meth= ods are <span class=3D"langinline">selectPath</span> and <span clas= s=3D"langinline">execQuery</span>, and you can call them from <a hr= ef=3D"../reference/org/apache/xmlbeans/XmlObject.html"><span class=3D"langi= nline">XmlObject</span></a> (or an object inheriting from it) or <a= href=3D"../reference/org/apache/xmlbeans/XmlCursor.html"><span class=3D"la= nginline">XmlCursor</span></a>. The results for the methods differ = somewhat. </p> <p class=3D"notepara"><strong>Note:</strong> Be sure to = see the XMLBeans <a href=3D"../../../documentation/conInstallGuide.html">in= stallation instructions</a> for getting full support for XPath and XQuery. = </p> <h2>Using the selectPath Method</h2> </div> <div> <p>The <span c= lass=3D"langinline">selectPath</span> method is the most efficient way = to execute XPath expressions. The <span class=3D"langinline">selectPath</sp= an> method is optimized for XPath. When you use XPath with the <span cl= ass=3D"langinline">selectPath</span> method, the value returned is an a= rray of values from the <em>current document</em>. In contrast, when yo= u use <span class=3D"langinline">execQuery</span>, the value returned i= s a <em>new document</em>.</p> <p> Note that XPath itself does not prov= ide syntax for declaring prefix to URI bindings. For user convenience, we a= llow XQuery syntax to be used for such purposes. You can consult the latest= XQuery draft when using syntax for declaring namespaces.</p> <h3>Callin= g from XmlObject</h3> <p>When called from <span class=3D"langinline">XmlO= bject</span> (or a type that inherits from it), this method returns an = array of objects. If the expression is executed against types generated= from schema, then the type for the returned array is one of the Java t= ypes corresponding to the schema. </p> <p>For example, imagine you have t= he following XML containing employee information. You've compiled the s= chema describing this XML and the types generated from schema are avail= able to your code.</p> <pre> &lt;xq:employees xmlns:xq=3D&quot;http://openu= ri.org/selectPath&quot;&gt; &lt;xq:employee&gt; &lt;xq:name&gt;= Fred Jones&lt;/xq:name&gt; &lt;xq:address location=3D&quot;home&quo= t;&gt; &lt;xq:street&gt;900 Aurora Ave.&lt;/xq:street&gt; = &lt;xq:city&gt;Seattle&lt;/xq:city&gt; &lt;xq:state&gt;W= A&lt;/xq:state&gt; &lt;xq:zip&gt;98115&lt;/xq:zip&gt; &= lt;/xq:address&gt; &lt;xq:address location=3D&quot;work&quot;&gt; = &lt;xq:street&gt;2011 152nd Avenue NE&lt;/xq:street&gt; = &lt;xq:city&gt;Redmond&lt;/xq:city&gt; &lt;xq:state&gt;WA&l= t;/xq:state&gt; &lt;xq:zip&gt;98052&lt;/xq:zip&gt; &lt;= /xq:address&gt; &lt;xq:phone location=3D&quot;work&quot;&gt;(425)55= 5-5665&lt;/xq:phone&gt; &lt;xq:phone location=3D&quot;home&quot;&gt= ;(217)429-5357&lt;/xq:phone&gt; &lt;xq:phone location=3D&quot;mobil= e&quot;&gt;(217)429-5357&lt;/xq:phone&gt; &lt;/xq:employee&gt; &lt;/xq:= employees&gt; </pre> If you wanted to find the phone numbers whose area c= ode was 206, you could capture the XPath expression in this way: <pre> = String queryExpression =3D &quot;declare namespace xq=3D'http://openuri= .org/selectPath';&quot; + &quot;$this/xq:employees/xq:employee/xq:phone= [contains(., '(206)')]&quot; </pre> <p>Notice in the query expression tha= t the variable <span class=3D"langinline">$this</span> represents the c= urrent context node (the <span class=3D"langinline">XmlObject</span> th= at you are querying from). In this example you are querying from the docume= nt level <span class=3D"langinline">XmlObject</span>.</p> <p>You coul= d then print the results with code such as the following:</p> <pre> /* *= Retrieve the matching phone elements and assign the results to the corresp= onding * generated type. */ PhoneType[] phones =3D (PhoneType[])empDoc.se= lectPath(queryExpression); /* * Loop through the results, printing the val= ue of the phone element. */ for (int i =3D 0; i < phones.length; i++) { = System.out.println(phones[i].stringValue()); } </pre> <h3>Calling fro= m XmlCursor</h3> <p>When called from an <span class=3D"langinline">XmlCur= sor</span> instance, the <span class=3D"langinline">selectPath</span> m= ethod retrieves a list of selections, or locations in the XML. The sele= ctions are remembered by the cursor instance. You can use methods such = as <span class=3D"langinline">toNextSelection</span> to navigate among = them.</p> <div> <p>The <span class=3D"langinline">selectPath</span> m= ethod takes an XPath expression. If the expression returns any result= s, each of those results is added as a selection to the cursor's list= of selections. You can move through these selections in the way you = might use <span class=3D"langinline">java.util.Iterator</span> method= s to move through a collection.</p> <p> For example, for a path such as= <span class=3D"langinline">$this/employees/employee</span>, the resu= lts would include a selection for each employee element found by the = expression. Note that the variable <span class=3D"langinline">$this</span> = is always bound to the current context node, which in this example is= the document. After calling the <span class=3D"langinline">selectPat= h</span> method, you would use various &quot;selection&quot;-related = methods to work with the results. These methods include:</p> </div>= <ul> <li> <div><span class=3D"langinline">getSelectionCount() = </span>to retrieve the number of selections resulting from the quer= y=2E</div> </li> <li> <div> <span class=3D"langinline">toNext= Selection()</span> to move the cursor to the next selection in the = list (such as to the one pointing at the next employee element foun= d).</div> </li> <li> <div> <span class=3D"langinline">toSelec= tion(int)</span> to move the cursor to the selection at the specifi= ed index (such as to the third employee element in the selection).<= /div> </li> <li> <div> <span class=3D"langinline">hasNextSele= ction()</span> to find out if there are more selections after the c= ursor's current position.</div> </li> <li> <div><span class= =3D"langinline"> clearSelections()</span> clears the selections fro= m the current cursor. This doesn't modify the document (in other words, = it doesn't delete the selected XML); it merely clears the selection li= st so that the cursor is no longer keeping track of those positions= .</div> </li> </ul> <div> <p>The following example shows how yo= u might use <span class=3D"langinline">selectPath</span>, in combinat= ion with the <span class=3D"langinline">push</span> and <span class=3D"lang= inline">pop</span> methods, to maneuver through XML, retrieving speci= fic values. </p> <pre> public void printZipsAndWorkPhones(XmlObject xml= ) { // Declare the namespace that will be used. String xqNamespace = =3D &quot;declare namespace xq=3D'http://openuri.org/selectPath';&q= uot;; // Insert a cursor and move it to the
{'source': 'Apache Software Foundation Public Mail Archives'}