on 08-17-2005 11:41 AM
Hi all,
we need after each closing tag in a XML file a carriage return. We use the file adapter without file content conversion.
e.g.:
The output should be:
<?xml version="1.0" encoding="UTF-8" ?>
- <TF_BORDERO>
<TF_VERSION>02.51</TF_VERSION>
<TF_UPDATE>I</TF_UPDATE>
<TF_CODEPAGE>UTF-8</TF_CODEPAGE>
<ADR_ADRID>1006000061</ADR_ADRID>
<TF_ERSTDAT>20050817</TF_ERSTDAT>
<TF_FLAG>P</TF_FLAG>
But it is:
<?xml version="1.0" encoding="UTF-8"?>
<TF_BORDERO><TF_VERSION>02.51</TF_VERSION><TF_UPDATE>I</TF_UPDATE><TF_CODEPAGE>UTF-8</TF_CODEPAGE><ADR_ADRID>1006000061</ADR_ADRID><TF_ERSTDAT>20050817</TF_ERSTDAT><TF_FLAG>P</TF_FLAG>
Is there any possibility with using a module with parameter settings or something else?
Hi Thomas,
You could use an Identity Transform XSLT Map and specify that it indents the XML. This will add a carriage return after each line. Here's the XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<!--
XI Mapping StyleSheet
Name: IdentityTransform.xsl
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<!-- Identity Transform
Copy the source XML to the output without any changes -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Why do you need to do this? XML Parsers should be able to handle the file either way.
Thanks,
Jesse
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had the same problem while sending IDOCs through the email adapter.
One partner had also trouble in processing such messages without CR, because in a email server or somewhere between the email adpater and the receiver the line is truncated suddenly with a CR, and this occurs somewhere.
In this case the XML is invalid then.
We solved the problem with t simple JAVA coding like the XSL coding.
Now I add this JAVA coding for all outgoing message to avoid this problems.
best regards
Werner
Hello Thomas,
sorry for the late answer.
Here is the part of the coding.
There is nothing special about conversion,
I just call the parser and return the XML stream back.
The parser itself provides this conversion with CR/LF.
I think it is not the best way to do this, but it works fine and it was very easy.
best regards
Werner
public void execute(InputStream in, OutputStream out) throws StreamTransformationException
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(in);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer t = tFactory.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.transform(new DOMSource(doc), new StreamResult(out));
}
catch(Exception e)
{
e.printStackTrace();
throw new StreamTransformationException("Mapping Error!", e);
}
}
Your XML looks wrong to me because it does not have a closing tag for TF_BORDERO element.
Check your XML file. May be you did not post the entire XML.
One other thing, it is only a represention to see each tag in a line, if you use XMLSpy or any other XML tool, you can see them the way you are expecting.
regards
SKM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
there is no standard to add the carriage return in xml.
You have to use Java/Abap Mapping or XSLT mapping to create the CR characters.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you tried to use text mode in your file adapter instead of binary?
BR,
Jürgen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.