cancel
Showing results for 
Search instead for 
Did you mean: 

Remove first line in the XML Document

Former Member
0 Kudos

Hi Friends,

In my File to File scenario when ever new mesg is appending to file at receiver side,it should remove <?xml version="1.0" encoding="ISO-8859-1"?> tag from the XML Document.This means <?xml version="1.0" encoding="ISO-8859-1"?> tag should appear once in a document.Plz suggest me to do this.

Thanks

pullarao.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey

as pointed out by everyone else,there is no straight way for this,one thing u can do is that create two separate scenarios.

in first scenario use content conversion on receiver side and keep on appending the text to a flat file,now since ur using FCC u wont get <?xml version="1.0" encoding="ISO-8859-1"?>,you will get a flat file on receiver side.

after some time(whatever ur pollin interval is) u can have one more scenario which picks up this flat file and this time use FCC on sender side so that it will convert this flat file to XML,in this way you will get <?xml version="1.0" encoding="ISO-8859-1"?> only once.

hope this solves ur problem.

just make sure that you specify correct polling intervals for both the scenarios.

thanx

ahmad

Former Member
0 Kudos

Hi,

My problem resolved.Thanks a lot to u all.

Thanks

pullarao

Answers (2)

Answers (2)

henrique_pinto
Active Contributor
0 Kudos

Hi there,

you can either use XSLT (with output type="text") or Java, using the code:

...
try {
  DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
  Document doc = docBuilder.parse(in);

  TransformerFactory tf = TransformerFactory.newInstance();
  Transformer trans = tf.newTransformer();
  trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

  DOMSource source = new DOMSource(doc);
  OutputStream out = new ByteArrayOutputStream();
  trans.transform(source, new StreamResult(out));

} catch (...

But as Bhavesh said, append mode is not recommended for XML files.

Best approach is collect pattern on BPM.

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

A Valid XML Document will always have this as the first line of your document. There is no way you can create a XML document without this line and even if you do then this is not a valid XML.

Why do you want to do this?

Regards

Bhavesh

Former Member
0 Kudos

Hello Bhavesh,

In my file to file scenario,i'm appending every new mesg to the XML file.File already have one <?xml> tag and it is valid mesg but the problem is when i was append the new mesg to valid mesg its appending with another <?xml> tag,I need to remove <?xml> tag from every new mesg while appending.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

The Append Mode in the receiver File Adapter is recommened / should be used only with text files ( i.e when you have Content Conversion in the Receiver File Adapter ).

In your case, as with an XML you are using Append mode, the Final Output file is not a valid XML.

Even if you do remove the first line of the XML document ( using either a module or a java mapping ) , the document will not be a valid XML as the document will not have a ROOT node. You will have to consider using another option other than Append mode on the receievr file adapter .

Regards

Bhavesh

Former Member
0 Kudos

HI,

The same question was already discussed earlier.

See take the file content conversion parameters , i mean conver the file into text file, use the append.Here maintaine the structure to contain multiple rows.

root ---0..unbound

strucutre...

At end of the append time, conver it into XML file and use it for further use.

Or the same file when you are using as input to another scenario use sender side FCC to conver it into xml.

i hoep it is clear.

OR there is an option in BPM, collect all the messages for certain period , at end of period send to file (it may be the xml).

Regards

Chilla