SAXParseException: "s4s-elt-character: Non-whitespace characters are not allowed in schema elements"
Asked Answered
P

4

5

I'm developing an Java application who read some data from an xml file. Trying to execute, I get this error:

org.xml.sax.SAXParseException; systemId: file:/c:/myxmlfile.xml; lineNumber: 7; columnNumber: 55; s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'My Name Value'.

My xml file starts with:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gdl_set xmlns="http://www.mywebsite.com"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.mywebsite.com/myxsddefinition.xsd"
     shortname="Shortname">
<name>My Name Value</name>

Can you help me to understand where's the problem?

Preengage answered 2/1, 2013 at 17:21 Comment(3)
Can you show us exactly what your Java application does to " read some data from an xml file"? The error message sounds as if a normal XML instance document is parsed as a schema but it is hard to tell why that happens without seeing details of your code.Syneresis
Due to an ambiguous variable naming, I was exchanging the xml file with its related xsd. Thank you!Preengage
I'm getting the same issue. What exactly did you do to fix it?Tourane
F
5

Yes I also got the same issue, then I found the that I was passing the XSD file as an input of XML file.

Like that -

String xsdPath= "122015/1224/sample.xml";
String **xmlPath** = "122015/1224/sample.xsd";
Funnelform answered 24/12, 2015 at 18:13 Comment(1)
This is a surprisingly easy mistake to make since there is no type differentiation. I did it too.Dunn
J
4

It looks to me as if the parser is for some reason trying to process your instance document as a schema file.

Jackstraws answered 2/1, 2013 at 18:13 Comment(1)
Due to an ambiguous variable naming, I was exchanging the xml file with its related xsd. Thank you!Preengage
M
1

I got the same error when I was trying to validate a Transformation file.

The reason I was getting the error was because I was validating it with an XML file instead of an XSD. In my project, they both have the same name. So I mistakenly gave the name of the XML file in place of XSD.

Once I changed that, it was working as expected. So, see if that is the problem in your case if the above solutions did not work.

Maleficence answered 8/10, 2015 at 9:58 Comment(0)
W
0

I was using:

<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>

and not 1.6 version and in 2.2 version you can specify:

<sources>
     <source>src/main/resources/masteraccount/</source>
</sources>

but I forgot to add

<xjcSourceExcludeFilters>
    <filter implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
        <patterns>
            <pattern>\.xml</pattern>
        </patterns>
    </filter>
</xjcSourceExcludeFilters>

which disables the use of .xml files. In my case plugin was trying to use .xml file but the correct my schema was in .xsd file.

Wearing answered 27/7, 2016 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.