Skip to content

Commit

Permalink
Remove unnecessary rewriting of XML schema location
Browse files Browse the repository at this point in the history
  • Loading branch information
atextor committed Nov 9, 2023
1 parent 43c4475 commit 605e74d
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
Expand Down Expand Up @@ -108,7 +107,7 @@ protected ByteArrayOutputStream generateXmlOutput( final Map<Aspect, JsonNode> a
try ( final ByteArrayOutputStream out = new ByteArrayOutputStream() ) {
final XmlSerializer serializer = new XmlSerializer();
serializer.write( out, mergedEnvironment );
return fixSchemaLocation( out );
return out;
} catch ( final SerializationException e ) {
throw new IOException( e );
}
Expand Down Expand Up @@ -150,25 +149,9 @@ protected ByteArrayOutputStream generate( final Serializer serializer, final Asp

try ( final ByteArrayOutputStream out = new ByteArrayOutputStream() ) {
serializer.write( out, environment );
// TODO must be removed as soon as https://github.com/eclipse-esmf/esmf-sdk/issues/461 is fixed
if(serializer instanceof XmlSerializer) {
return fixSchemaLocation( out );
}
return out;
} catch ( final SerializationException e ) {
throw new IOException( e );
}
}

// TODO must be removed as soon as https://github.com/eclipse-esmf/esmf-sdk/issues/461 is fixed
private ByteArrayOutputStream fixSchemaLocation(ByteArrayOutputStream out) throws IOException {
String document = out.toString( StandardCharsets.UTF_8 );
String result = document.replace(
"https://admin-shell.io/aas/3/0 AAS.xsd",
"https://admin-shell.io/aas/3/0/AAS.xsd" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write( result.getBytes( StandardCharsets.UTF_8 ) );
return baos;

}
}

0 comments on commit 605e74d

Please sign in to comment.