|
|
|
Re: XML Namespace not being propagated [message #1758569 is a reply to message #1758537] |
Thu, 30 March 2017 08:07 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
I generated the model and the test project for https://www.hl7.org/fhir/fhir-all.xsd and used the FhirExample.java to test your assertions. I changed the example like this: Resource resource = resourceSet.createResource(URI.createURI("http:///My.fhir"));
DocumentRoot documentRoot = FhirFactory.eINSTANCE.createDocumentRoot();
Parameters params = FhirFactory.eINSTANCE.createParameters();
ParametersParameter param = FhirFactory.eINSTANCE.createParametersParameter();
params.getParameter().add(param);
documentRoot.setParameters(params);
resource.getContents().add(documentRoot);
resource.save(System.out, null); and running it produces this:<?xml version="1.0" encoding="ASCII"?>
<fhir:Parameters xmlns:fhir="http://hl7.org/fhir">
<fhir:parameter/>
</fhir:Parameters> If I comment out all the options in the generated resource factory: public Resource createResource(URI uri)
{
XMLResource result = new FhirResourceImpl(uri);
// result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
//
// result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
//
// result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
// result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
//
// result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
} it products this<?xml version="1.0" encoding="ASCII"?>
<fhir:DocumentRoot xmlns:fhir="http://hl7.org/fhir">
<parameters>
<parameter/>
</parameters>
</fhir:DocumentRoot> If I now change the example to this: Resource resource = resourceSet.createResource(URI.createURI("http:///My.fhir"));
Parameters params = FhirFactory.eINSTANCE.createParameters();
ParametersParameter param = FhirFactory.eINSTANCE.createParametersParameter();
params.getParameter().add(param);
resource.getContents().add(params);
resource.save(System.out, null); then it produces:<?xml version="1.0" encoding="ASCII"?>
<fhir:Parameters xmlns:fhir="http://hl7.org/fhir">
<parameter/>
</fhir:Parameters> That's what you are apparently seeing, so I think you're not using the generated resource factory to create the resource that you're using to produce the serialization you're showing.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03210 seconds