0

Issue: No annotation provided for adding XSI location to root. Another stackoverflow question detailed the same problem but in C#. I'm not quite sure how to covert that over to JAVA. I need to update XML in a flat file and thought of just using string manipulation to add the XSI locations but I was hoping there might be a cleaner approach.

Reference Question: C# Stackoverflow Same Issue

Sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MySample xmlns:ns0="someurl" xsi:schemaLocation="someOtherurl">
<othertag/>
</ns0:MySample>
Community
  • 1
  • 1
haju
  • 1,278
  • 4
  • 20
  • 38

1 Answers1

1

Since it the schemaLocation is an attribute and not a namespace you can simply parse it using @Attribute annotation.

@Attribute
private String schemaLocation;

Do not forget to declare the Namespace of the root element:

@Namespace(prefix="xsi", reference="http://www.w3.org/2001/XMLSchema-instance"),

This worked just fine for me.

Alex
  • 11
  • 1