You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2009/04/17 18:57:14 UTC
[jira] Resolved: (XERCESJ-1367) UTF encoding not always properly
detected -> Content is not allowed in prolog error
[ https://issues.apache.org/jira/browse/XERCESJ-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich resolved XERCESJ-1367.
-------------------------------------------
Resolution: Invalid
"http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/Invoice.xsd" parses just fine with the latest code.
Getting "Content is not allowed" is almost always a sign of a usage error and based on what you've said it's Castor or whatever code which invoked the parser that is taking responsibility for doing the decoding because it specified a java.io.Reader as input. In such cases Xerces has no role in detecting the encoding or decoding the characters. It just consumes whatever chars were returned from the java.io.Reader. If the chars coming out of it are not correct then that is the fault of the calling application.
> UTF encoding not always properly detected -> Content is not allowed in prolog error
> -----------------------------------------------------------------------------------
>
> Key: XERCESJ-1367
> URL: https://issues.apache.org/jira/browse/XERCESJ-1367
> Project: Xerces2-J
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.9.1
> Environment: Using Castor XML schema source generator on URL http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/Invoice.xsd
> It has several includes, some with UTF-8 and others with UTF-16
> Reporter: Sander Postma
>
> I was getting "Content is not allowed in prolog" errors like described here:
> http://www.mail-archive.com/dev@castor.codehaus.org/msg00657.html
> After a debug session I found out the input stream encoding was not detected. It was on my primary document, but not on the includes.
> A simple // was enough to fix the problem for me. Please see the row marked below --------->
> org.apache.xerces.impl.XMLEntityManager:
> public String setupCurrentEntity(String name, XMLInputSource xmlInputSource,
> boolean literal, boolean isExternal)
> throws IOException, XNIException {
> // get information
> final String publicId = xmlInputSource.getPublicId();
> String literalSystemId = xmlInputSource.getSystemId();
> String baseSystemId = xmlInputSource.getBaseSystemId();
> String encoding = xmlInputSource.getEncoding();
> final boolean encodingExternallySpecified = (encoding != null);
> Boolean isBigEndian = null;
> fTempByteBuffer = null;
> // create reader
> InputStream stream = null;
> ---------> Reader reader = null; // xmlInputSource.getCharacterStream();
> // First chance checking strict URI
> String expandedSystemId = expandSystemId(literalSystemId, baseSystemId, fStrictURI);
> if (baseSystemId == null) {
> baseSystemId = expandedSystemId;
> }
> if (reader == null) {
> stream = xmlInputSource.getByteStream();
> if (stream == null) {
> ...
> ...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org