Hi, all,
Have validation problem with "anyAttribute", here is XML schema fragment:
-----------------------------------------------------------------------------------
<xs:complexType name="documentsReturnType">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element minOccurs="1" maxOccurs="unbounded" name="document">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:token">
*<xs:anyAttribute namespace="" processContents="lax" />*
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"
processContents="lax" />
</xs:sequence>
/*<xs:anyAttribute namespace="" processContents="lax" />*/
</xs:complexType>
-----------------------------------------------------------------------------------
these two looks like being identical, but first of them cannnot pass
schema validation:
bolded line describes any attribute for "document" element
(PROBLEMATIC).
bold and itallic line describes any attribute for complexType
"documentReturnType" - it is OK.
here is XML file being parsed fragment:
-----------------------------------------------------------------------------------
<product AnyAttributeYouLike="Some Value">
<name>Sameday</name>
<documentsReturn AnyAttributeYouLike="Some Value">
* <document AnyAttributeYouLike="Some Value">string</document>
<document AnyAttributeYouLike="Some Value">string</document>
<document AnyAttributeYouLike="Some Value">string</document>*
<a:AnyElementYouLike xmlns:a="AnyThingButTheTargetNamesapce">Some
Data Or Other Elements</a:AnyElementYouLike>
<b:AnyElementYouLike xmlns:b="AnyThingButTheTargetNamesapce">Some
Data Or Other Elements</b:AnyElementYouLike>
<c:AnyElementYouLike xmlns:c="AnyThingButTheTargetNamesapce">Some
Data Or Other Elements</c:AnyElementYouLike>
<d:AnyElementYouLike xmlns:d="AnyThingButTheTargetNamesapce">Some
Data Or Other Elements</d:AnyElementYouLike>
</documentsReturn>
<e:AnyElementYouLike xmlns:e="AnyThingButTheTargetNamesapce">Some Data
Or Other Elements</e:AnyElementYouLike>
<f:AnyElementYouLike xmlns:f="AnyThingButTheTargetNamesapce">Some Data
Or Other Elements</f:AnyElementYouLike>
<g:AnyElementYouLike xmlns:g="AnyThingButTheTargetNamesapce">Some Data
Or Other Elements</g:AnyElementYouLike>
<h:AnyElementYouLike xmlns:h="AnyThingButTheTargetNamesapce">Some Data
Or Other Elements</h:AnyElementYouLike>
</product>
-----------------------------------------------------------------------------------
bolded lines did not pass validation, here are validation errors:
/
Attribute not allowed: AnyAttributeYouLike in element document
Attribute not allowed: AnyAttributeYouLike in element document
Attribute not allowed: AnyAttributeYouLike in element document/
here is xml validation Java code:
-----------------------------------------------------------------------------------
// Create an XmlOptions instance and set the error listener.
XmlOptions xmlOptions = new XmlOptions();
List errorList = new ArrayList();
xmlOptions.setErrorListener(errorList);
xmlOptions.setValidateTreatLaxAsSkip();
*xmlOptions.setLoadUseXMLReader(new org.apache.xerces.parsers.SAXParser());*
// load document
manifestsListDocument = ManifestsListDocument.Factory.parse(xmlFile,
xmlOptions);
// validate xml
if (!manifestsListDocument.validate(xmlOptions)) {
for (Object object : errorList) {
XmlError error = (XmlError)object;
if (logger.isEnabledFor(Level.ERROR))
logger.error(error.getMessage());
}
// failure
return false;
}
// success
return true;
-----------------------------------------------------------------------------------
bolded line is optional - i've tried to replace default xml parser by
provider xerces XMLReader implementation - it didn't helped, output did
not changed.
could someone help me to find solution?
--
Regards,
Aleksandr Bissekerskij
Programmer
UAB "DPD Lietuva"
Vilkpe.de.s g. 4
LT-03151 Vilnius, Lietuva
Fax + 370 5 210 6740
Mobile + 370 610 02602
E-mail [EMAIL PROTECTED]
http://www.dpd.lt