-1

I cannot get xsi:schemaLocation=http://example.com example.xsd to display after generating xml out from the xsd. Below is a sample of my xsd file. What could be the problem?

Sample XSD file

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com"     xmlns:xsi="http://example.com" elementFormDefault="qualified" xsi:schemaLocation="http://example.com example.xsd">
...
...
</xs:schema>

Present xml output

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tag1 xmlns="http://example.com">

...
...
...
</tag1>

Expected xml output

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tag1 xmlns="http://example.com" xsi:schemaLocation="http://example.com example.xsd">

...
...
...
</tag1>
Uarel
  • 11
  • 2
  • 2
    This is not a question about XSD and XML so much as about the tool you are using to generate the one from the other. If you don't name that tool, no one can tell you how to configure it to emit the schema-location information. – C. M. Sperberg-McQueen May 29 '14 at 13:39
  • I assumed the it was about setting xsi:schemaLocation="http://example.com example.xsd" & it was being set wrong. The tool used to convert xsd to xml is jaxb, a similar solution was found at http://stackoverflow.com/questions/2161350/jaxb-xjc-code-generation-schemalocation-missing-in-xml-generated-by-marshall – Uarel May 30 '14 at 02:05

1 Answers1

1

Found the solution posted at: JAXB xsd to xml

The answer was provided by xcut. The parameter xsi:schemaLocation="http://example.com example.xsd" has to be generated by using

marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://example.com example.xsd"); 
Community
  • 1
  • 1
Uarel
  • 11
  • 2