0

I know that there is a lot of such a topics online but the problem is, that none of solutions work for me. Language I'm using: Java IDE: Intellij

Just to make clear, I'm using community edition, maybe that's why none of plugins, like JAXB doesn't work.

From the other file I extracted data (values) and I need to create XML file with this data. Also there is XSD schema here: http://www.bpsim.org/schemas/1.0/

I'm thinking maybe there is any third-party solutions what I can use? Cause I really don't want to code all the XML file by hands cause it's thousands of values and code.

Anyone knows a good solution?

  • Possible duplicate of [Any Java "API" to generate Sample XML from XSD?](https://stackoverflow.com/questions/4710852/any-java-api-to-generate-sample-xml-from-xsd) – Gab Apr 30 '18 at 19:30
  • did you [checked this page](https://www.jetbrains.com/help/idea/generating-instance-document-from-xml-schema.html)? – LMC Apr 30 '18 at 19:50
  • Yeah, but it's not the same. Let's say, I have a lot of values and XSD schema. I need to make XML according to XSD with THESE specific values. XML file what I want to create is specific with correct _event_, _attribute_ names... – Justinas Indrašius May 01 '18 at 08:50
  • Also this one, what you sent me the last one, doesn't work. Error message: **There is no root element** – Justinas Indrašius May 01 '18 at 08:56
  • XSD schema is 100% correct cause I took it from official page – Justinas Indrašius May 01 '18 at 08:57

1 Answers1

2

On Linux you can use xsd2inst from xmlbeans, xmlbeans-tools packages to generate and instance out of the xsd

XMLBEANS_LIB='/usr/share/java/xmlbeans/' xsd2inst test.xsd -name shiporder> test.xml

xsd2inst -h

Generates a document based on the given Schema file
having the given element as root.
The tool makes reasonable attempts to create a valid document,
but this is not always possible since, for example,
there are schemas for which no valid instance document
can be produced.
Usage: xsd2inst [flags] schema.xsd -name element_name Flags:
-name the name of the root element
-dl enable network downloads for imports and includes
-nopvr disable particle valid (restriction) rule
-noupa disable unique particle attribution rule

LMC
  • 10,453
  • 2
  • 27
  • 52