Hi,
I have a problem using xerces-j 1.4 for validating XML-Documents with
XML-Schema. It
stripps Attribute values from the source document to empty strings.
Here is the code calling the validation:
// create the objects needed to perform validating and saving the
result.
byte[] xmlbuffer = byteresult.toByteArray();
xmlbuffercontent = "<p><pre>" + new String(xmlbuffer) + "</p></pre>";
ByteArrayInputStream bytesource = new ByteArrayInputStream(xmlbuffer);
// validate the result
validator.validate(bytesource,
getServletContext().getRealPath(request.getParameter("out")));
// save the result
FileOutputStream xmlsaveResult = new FileOutputStream(
new
File(getServletContext().getRealPath(request.getParameter("out"))));
xmlsaveResult.write(xmlbuffer);
xmlsaveResult.close();
} catch (Exception e) {
EditorServiceException te = new EditorServiceException("parse and save
result: " + e.getMessage() + "<br/>Document: " +
xmlbuffercontent);
throw te;
}
The Validator Class which contains the validate(InputStream bytesource, String DocId)
method I have attached.
I get the following error message:
<p>The following error has occured: </p></a><br><pre>EditorServiceException: parse and
save result: XMLEDIFACTValidationException:
Error: Datatype error: In element 'DocumentType' : Value '' must be one of [501, 502,
503, 504, 505, 551].
Error: Datatype error: In element 'TypeOfCase' : Value '' must be one of [0, 1, 2, 3,
8, 9].
Error: Attribute "Value" must be declared for element type "InstitutionType".
Error: Datatype error: In element 'InstitutionType' : Value '' must be one of [BCSS,
CNAV, DSS, GISS, INPS, SVB, VDR, RFV, KHYKY].
<br/>Document: <p><pre>
<?xml version="1.0" encoding="UTF-8"?>
<M_SSREGW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ssregw_xsd.xsd">
<DocumentType Value="501"/><DocumentDate>28052001</DocumentDate>
<TypeOfCase
Value="0"/><SendingInstitution><RegistrationNumber>007</RegistrationNumber></SendingInstitution>
<ReceivingInstitution><InstitutionType
Value="LVA"/></ReceivingInstitution><InsuredPerson><CurrentName>
<Surname>Mäsing</Surname></CurrentName></InsuredPerson></M_SSREGW>
With a similar DTD I get the following as I have expected:
<p>The following error has occured: </p></a><br><pre>EditorServiceException: parse and
save result: XMLEDIFACTValidationException:
Error: Attribute "Value" with value "LVA" must have a value from the list
"(BCSS|CNAV|DSS|GISS|INPS|SVB|VDR|RFV|KHYKY)".<br/>Document: <p><pre><?xml
version="1.0" encoding="UTF-8"?>
<!DOCTYPE M_SSREGW SYSTEM "ssregw_paper.dtd">
<M_SSREGW><DocumentType Value="501"/><DocumentDate>28052001</DocumentDate>
<TypeOfCase
Value="0"/><SendingInstitution><RegistrationNumber>007</RegistrationNumber></SendingInstitution>
<ReceivingInstitution><InstitutionType Value="LVA"/></ReceivingInstitution>
<InsuredPerson><CurrentName><Surname>Mäsing</Surname></CurrentName></InsuredPerson></M_SSREGW>
With DTDs my Code works fine.
So I do no know wether I have done something wrong (for example bad configuration) or
if it is a problem of xerces-j.
Can anyone give me a hint?
I have also attached the schema.
Regards
Thomas
(See attached file: Examples.ZIP)
.ZIP File
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]