Pb parseur XML: Content is not allowed in pro
marsupilamuf
Messages postés
10
Statut
Membre
-
kij_82 Messages postés 4102 Date d'inscription Statut Contributeur Dernière intervention -
kij_82 Messages postés 4102 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour tout le monde.
J'utilise Castor XML pour générer des classes Java à partir d'un fichier xsd.
Lorsque je lui demande de m'ouvrir le fichier (unmarshall) il me sort l'erreur suivante:
Unmarshalling file
org.xml.sax.SAXException: Parsing Error : Content is not allowed in prolog.
Line : 1
Column : 1
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at com.pad.bean.messageT2000.NCA_Arrival.unmarshal(NCA_Arrival.java:91)
at testT2000.main(testT2000.java:35)
Je comprend absolument pas d'ou ca viens. Si quelqu'un peut m'aider se serait sympa
Merci à tous
Houba by by
J'utilise Castor XML pour générer des classes Java à partir d'un fichier xsd.
Lorsque je lui demande de m'ouvrir le fichier (unmarshall) il me sort l'erreur suivante:
Unmarshalling file
org.xml.sax.SAXException: Parsing Error : Content is not allowed in prolog.
Line : 1
Column : 1
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at com.pad.bean.messageT2000.NCA_Arrival.unmarshal(NCA_Arrival.java:91)
at testT2000.main(testT2000.java:35)
Je comprend absolument pas d'ou ca viens. Si quelqu'un peut m'aider se serait sympa
Merci à tous
Houba by by
2 réponses
-
Voilà la réponse, je cite :
byte order mark Also known as BOM. Name given to the Unicode character U+FEFF when used at the beginning of a Unicode byte stream. This invisible character generally know as ZERO WIDTH NO-BREAK SPACE (ZWNBSP) serves to identify unambiguously the Unicode transformation form used (and especially the byte order) for the stream. Indeed U+FFFE is a noncharacter so there is no risk of misinterpretation. The following represents the byte signature of the character U+FEFF with the various Unicode Transformation Forms: Bytes Encoding 00 00 FE FF UTF-32, big-endian FF FE 00 00 UTF-32, little-endian FE FF UTF-16, big-endian FF FE UTF-16, little-endian EF BB BF UTF-8 Historically the ZWNBSP was also used to indicate non-breaking but this use is now deprecated and replaced by the character U+2060 for that purpose. " https://p2p.wrox.com/index.php " I suspect you edited the stylesheet using a text editor that inserts the BOM at the start of the file. For example, I think Windows Notepad does this. Some XML parsers accept a BOM at the start of a UTF-8 file, others don't. For example, the Crimson parser that comes with JDK 1.4 doesn't. You basically need to find a text editor and an XML parser that agree with each other about whether or not to use a byte order mark. Alternatively, use a different encoding for the stylesheet, e.g. iso-8859-1. " The code above found these strange bytes while expecting '<', and crashed of course.
Pour ma part j'ai effectivement ouvert l'un de mes fichiers avec notePad, ce qui a pour effet d'écrire un BOM au début du fichier, ce qui fait planter le SAXParser.
Soit il faut passer l'encoding en UTF-16 soit ne pas ouvrir le fichier avec notePad ou un éditeur de texte ayant un comportement analogue (lesquels ?!)
-
Quelqun aurait il la solution à cette enigme ? Ca m'intéresse car j'ai le meme soucis actuellement.
Je pense qu'il faut chercher du coté de caractère spéciaux invisible (non interprété) sur certaines plateforme, car j'ai aucun probleme sous window/eclipse, par contre lorsque j'exécute mon prog java depuis un JCL ou via un script shell, j'ai ce type d'erreur.
??