Hi all,
Used Xerces Version: 2.2.0
During the validation of a XML file using SAX parser, when xs:list is used,
validation fails.
Is there any way to get the same requirement of having a list satisfied ?
Error Message given by the SAX Parser is
Message: Datatype error: Type:InvalidDatatypeValueException, Message:Value
'SAVE_PRIVATE_TASKS ALIGN_ALARM_STATUS' is not in enumeration .
Schema is
<xs:simpleType name="USERPRIVILEGESLIST">
<xs:list itemType="NONEMPTYSTRING"/>
</xs:simpleType>
<xs:simpleType name="USERPRIVILEGES">
<xs:restriction base="USERPRIVILEGESLIST">
<xs:maxLength value="7"/>
<xs:minLength value="1"/>
<xs:enumeration value="ALIGN_ALARM_STATUS"/>
<xs:enumeration value="CLEAR_ALARMS"/>
<xs:enumeration
value="CLEAR_AUTOMATICALLY_CLEARABLE_ALARMS"/>
<xs:enumeration value="CONFIRM_ALARMS"/>
<xs:enumeration value="CREATE_WORK_ORDER"/>
<xs:enumeration value="VIEW_SECURITY_ALARMS"/>
<xs:enumeration value="SAVE_PRIVATE_TASKS"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CreateAdminDBUser">
<!-- Optional Parameters -->
<xs:attribute name="ContinueOnError" type="xs:boolean"/>
<xs:attribute name="SuccessLogString" type="xs:string"/>
<xs:attribute name="ErrorLogString" type="xs:string"/>
<!-- Mandatory Parameters -->
<xs:attribute name="UserName"
type="NONEMPTYSTRING" use="required"/>
<xs:attribute name="UserPwd"
type="NONEMPTYSTRING"/>
<xs:attribute name="ApplicationList" type="xs:string"
use="required"/>
<xs:attribute name="UGList" type="xs:string"
use="required"/>
<!--xs:attribute name="Privilege"
type="USERPRIVILEGES" use="required"/-->
<xs:attribute name="Privilege"
type="NONEMPTYSTRING" use="required"/>
</xs:complexType>
Usage in XML file
<CreateAdminDBUser UserName="%%FIRST_ADMIN_USER%%"
UserPwd="%%FIRST_ADMIN_USER_PWD%%" ApplicationList="" UGList=""
Privilege="SAVE_PRIVATE_TASKS ALIGN_ALARM_STATUS"/>
Code used for parsing is
strTmpXMLFilePath is the xml file name.
m_strSchemaFileName is the Schema file name.
SAX2XMLReader* m_pXMLParser;
//Set the External Schema File Name.
try
{
XMLCh* propertyValue =
(LPTSTR)(LPCTSTR)m_strSchemaFileName;
m_pXMLParser->setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLoc
ation,propertyValue);
}
catch(const SAXException& toCatch)
{
return ERR_FAILURE;
}
catch (...)
{
strTraceMessage.Format(_T("ERROR: Unexpected
exception during setting the external \
schema file name :
%s"),m_strSchemaFileName);
cout << strTraceMessage;
return ERR_FAILURE;
}
//Parse the XML file.
try
{
m_pXMLParser->parse(strTmpXMLFilePath);
}
catch (const XMLException& toCatch)
{
strTraceMessage.Format(_T("ERROR: Error during
parsing the given file ! Message: %s"),
toCatch.getMessage());
cout << strTraceMessage;
return ERR_FAILURE;
}
catch (...)
{
strTraceMessage.Format(_T("ERROR: Unexpected
exception during parsing: %s"),strTmpXMLFilePath);
cout << strTraceMessage;
return ERR_FAILURE;
}
Best Regards,
Swaminathan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]