cancel
Showing results for 
Search instead for 
Did you mean: 

how to add an xml start tag to an xml document?

Former Member
0 Kudos

Hi

I would like to add this xml tag to my xml document i PI 7.1:

<?xml-stylesheet type="text/xsl" href="xcbl_invoice_stylesheet.xsl" ?>

Before:

<Invoice>

<InvoiceHeader>

<InvoiceNumber>

<Reference>

<RefNum>8858382</RefNum>

</Reference>

</InvoiceNumber>

......

after:

<?xml-stylesheet type="text/xsl" href="xcbl_invoice_stylesheet.xsl" ?>

<Invoice>

<InvoiceHeader>

<InvoiceNumber>

<Reference>

<RefNum>8858382</RefNum>

</Reference>

</InvoiceNumber>

......

What is the esiest way to do that?

BR

MIkael

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member187339
Active Contributor
0 Kudos

Hi,

You can use java mapping to add the same

in interface determination :

1. First mapping will convert the source to target structure

2. Second mapping (java mapping) will add the necessary <xsl> tag

Regards

Suraj

Former Member
0 Kudos

Hi Suraj

Thanks for the answer. Should I just use the startDocument() method and in that method call the startElement method?

BR

Mikael

Former Member
0 Kudos

Or maybe something like this:

public void startDocument() throws SAXException {

out.write("<?xml-stylesheet type="text/xsl" href="xcbl_invoice_stylesheet.xsl" ?>");

.....

?

BR

MIkael

former_member187339
Active Contributor
0 Kudos

Hi,

I meant to read the entire source into a stringbuffer. Append xsl structure to it and convert it directly to a XML structure.

Never thought of including DOM or SAX technology

Something like this:


DOMParser parser = new DOMParser();
parser.parse(new InputSource(new java.io.StringReader(xml))); // xml is a
string containing xml
Document doc = parser.getDocument();

Regards

Suraj

Edited by: S.R.Suraj on Sep 10, 2009 9:27 AM