|
Loading...
|
xsl-list@lists.mulberrytech.com
[Prev] Thread [Next] | [Prev] Date [Next]
Re: [xsl] adding element in with general namespace prefix Wendell Piez Wed Feb 08 14:01:54 2012
Ram,Maybe you want to use xsl:copy, which may do better for you. Most processors, when copying an element, will use the same prefix as the input document uses.
Or it may not: as Ken says, processors are not obliged to respect prefixes since a prefix is not properly part of the name, as formally defined; it is only a (local) binding mechanism.
If you are answering a requirement from a partner who does not understand this, you can, in XSLT 2.0, go to considerably more work to construct elements with namespaces, names and their prefixes generated dynamically, using XPath functions such as name(), prefix-from-QName(), and namespace-uri-for-prefix(). An XSLT stylesheet could generate a new header using whatever prefix the input uses, whatever it is -- although such a stylesheet will look pretty mysterious to the uninitiated.
But this is not trivial to do, and a lot of trouble to go to for something that matters only because someone thinks it matters. Even worse, if you are addressing a set of requirements that have never been articulated, which you have only because someone at some point might be unhappy about something ... well. That's a difficult problem to solve.
Cheers, Wendell On 2/8/2012 4:46 PM, ram wrote:
i completly agree with you, but some time service provider may not like it when he sees the request, he may question, why are you keeping different namespace prefix for same namespace. i wanted to be consistent in the entire soap request that i am sending --- On Thu, 9/2/12, G. Ken Holman<[EMAIL PROTECTED]> wrote:From: G. Ken Holman<[EMAIL PROTECTED]> Subject: Re: [xsl] adding element in with general namespace prefix To: [EMAIL PROTECTED], [EMAIL PROTECTED] Date: Thursday, 9 February, 2012, 3:11 AM A true XML application ignores the namespace prefix and relies only on the namespace URI associated with the namespace prefix. Can you explain why it is important to you that the prefix be the same? It is irrelevant. This request is equivalent to an XML-based namespace-aware application: <giraffe:Envelope xmlns:giraffe="http://schemas.xmlsoap.org/soap/envelope/"> An XML application will still see the above as a SOAP envelope. At 2012-02-09 03:06 +0530, ram wrote:So any idea how to fixit. It isn't broken. I hope this helps. . . . . . . . . . . Ken At 2012-02-09 03:06 +0530, ram wrote:Hi, I have a soap request like the following <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con1="http://abc.com/DefService/"><soapenv:Header></soapenv:Header><soapenv:Body><con1:GetDefinition><!--Optional:--><con1:Request><con1:Id/></con1:Request></con1:GetDefinition></soapenv:Body></soapenv:Envelope> I wanted to add ws:security with username credentials tothe requestlike the following. <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:con="http://wellpoint.com/esb/context" xmlns:con1="http://abc.com/DefService/> <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken><wsse:Username>abcd</wsse:Username><wsse:Password>ramkurra</wsse:Password></wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <con1:GetDefinition> <con1:Id/></con1:Response></con1:GetDefinition> </soapenv:Body> </soapenv:Envelope> i tried with the following piece of code <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template> <xsl:templatematch="/*[local-name()='Envelope']/*[local-name()='Header']"><soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>abc</wsse:Username><wsse:Password>xya</wsse:Password></wsse:UsernameToken> </wsse:Security> </soapenv:Header> </xsl:template> </xsl:stylesheet> i get the result as expected,but my problem is when clientsends the request with different namespace name ratherthansoapenv:Header, like s:Header, the following line ofcode willstill put soapenv:Header in the result <soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> I wanted to make this namespace prefix ismore of generalizedmanner, which picks from request. So any idea how to fixit. -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0& 2.0 http://ude.my/uoui9h Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:[EMAIL PROTECTED] Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal --~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail:<mailto:[EMAIL PROTECTED]> --~----~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail:<mailto:[EMAIL PROTECTED]> --~--
-- ====================================================================== Wendell Piez mailto:[EMAIL PROTECTED] Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== --~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:[EMAIL PROTECTED]> --~--
- [xsl] adding element in with general namespace prefix ram 2012/02/08
- Message not available
- Re: [xsl] adding element in with general namespace prefix G. Ken Holman 2012/02/08
- Re: [xsl] adding element in with general namespace prefix ram 2012/02/08
- Message not available
- Re: [xsl] adding element in with general namespace prefix G. Ken Holman 2012/02/08
- Re: [xsl] adding element in with general namespace prefix ram 2012/02/08
- Message not available
- Re: [xsl] adding element in with general namespace prefix G. Ken Holman 2012/02/08
- Message not available
- Re: [xsl] adding element in with general namespace prefix G. Ken Holman 2012/02/08
- Re: [xsl] adding element in with general namespace prefix Wendell Piez 2012/02/08 <=
- Re: [xsl] adding element in with general namespace prefix Michael Kay 2012/02/08