Subject: Re: [xsl] Adding tag to SOAP From: António Mota <amsmota@xxxxxxxxx> Date: Wed, 8 Feb 2006 09:58:42 +0000 |
Please don't take it wrong, but I don't understand what's the use of giving out solutions to problems without a single word of explanation about it. I even think it's better to only give the explanation and let the solution to the people that asked, at least that's the way i learned the few i things i know... So, let me try... By using <xsl:template match="/"> <xsl:copy-of select="." /> </xsl:template> you (Sashank) are saying "get the root element of the document and copy it to the output tree, including all the descendents it has (that's copy-of), and do nothing else with then" So the rest of your code it's never reached <xsl:template match="po"> <xsl:copy> <Id>a new id</Id> </xsl:copy> </xsl:template> because you're applyng templates only to the document node and not to it's children, "po" among then. No in Mukul code, he (Mukul) is saying "match every node in the document, copy it to the output, and in the meantime apply templates to it's children (wich in turn will copy then to the output too). <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*" /> </xsl:copy> </xsl:template> That way, when it matches a element = po, it applyes the template you've defined, otherwise apply the buil-in template, that is, copy it. <xsl:template match="po"> <xsl:copy> <Id>a new id</Id> </xsl:copy> </xsl:template> </xsl:stylesheet> I'm sure my explanation could be more acurate, but it gives a view of what's happening in there. Cheers. On 08/02/06, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote: > Please try this stylesheet > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> > > <xsl:output method="xml" indent="yes" /> > > <!-- identity template --> > <xsl:template match="node() | @*"> > <xsl:copy> > <xsl:apply-templates select="node() | @*" /> > </xsl:copy> > </xsl:template> > > <xsl:template match="po"> > <xsl:copy> > <xsl:apply-templates select="@*" /> > <Id>a new id</Id> > <xsl:apply-templates /> > </xsl:copy> > </xsl:template> > > </xsl:stylesheet> > > Regards, > Mukul > > > On 2/8/06, Shashank Gupta <gumnam_musafir@xxxxxxxxx> wrote: > > Hi, > > > > I have a SOAP message to which I want to add a tag. > > However, the message is output as is without the tag. > > > > Here is the xsl: > > > > <xsl:stylesheet version="1.0" > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:output method="xml" /> > > <xsl:template match="/"> > > <xsl:copy-of select="." /> > > </xsl:template> > > <xsl:template match="po"> > > <xsl:copy> > > <Id>a new id</Id> > > </xsl:copy> > > </xsl:template> > > </xsl:stylesheet> > > > > > > This is the message: > > > > <soapenv:Envelope > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <soapenv:Header> > > <wsse:Security > > xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext"> > > </wsse:Security> > > <Action>transfer</Action> > > </soapenv:Header> > > <soapenv:Body> > > <ns1:poSubmit > > soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > > xmlns:ns1="urn:po-submit"> > > <po xsi:type="xsd:string"> > > <PORequest> > > <testNum>3</testNum> > > <priceList>953</priceList> > > <quantity>1</quantity> > > <PONumber></PONumber> > > <CreditCardNos>4178908723456781</CreditCardNos> > > <Amount>56091.23</Amount> > > <RequestedShipDate>020606</RequestedShipDate> > > </PORequest> > > </po> > > </ns1:poSubmit> > > </soapenv:Body> > > </soapenv:Envelope> > > > > Requirement is the below: > > > > > > <soapenv:Envelope > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <soapenv:Header> > > <wsse:Security > > xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext"> > > </wsse:Security> > > <Action>transfer</Action> > > </soapenv:Header> > > <soapenv:Body> > > <ns1:poSubmit > > soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > > xmlns:ns1="urn:po-submit"> > > <po xsi:type="xsd:string"> > > <Id>a new id</Id> > > <PORequest> > > <testNum>3</testNum> > > <priceList>953</priceList> > > <quantity>1</quantity> > > <PONumber></PONumber> > > <CreditCardNos>4178908723456781</CreditCardNos> > > <Amount>56091.23</Amount> > > <RequestedShipDate>020606</RequestedShipDate> > > </PORequest> > > </po> > > </ns1:poSubmit> > > </soapenv:Body> > > </soapenv:Envelope> > > > > Thanks > > gumnam
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Adding tag to SOAP, Mukul Gandhi | Thread | [xsl] XSLT and InDesign Tagged Text, Jeff Sese |
RE: [xsl] Selecting the Latest Date, Michael Kay | Date | Re: [xsl] XSLT and InDesign Tagged , David Carlisle |
Month |