Last active
August 29, 2015 14:16
-
-
Save steppat/3da868e9ca88893b692a to your computer and use it in GitHub Desktop.
Template para adicionar cabeçalho na mensgagem SOAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" | |
version="1.0"> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- o template abaixo copia o XML inteiro --> | |
<!-- @* - seleciona todos os atributos --> | |
<!-- node() - seleciona todos os nodes --> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<!-- o template abaixo adiciona um Header e o elemento tokenUsuario se nao existe o Header ainda --> | |
<xsl:template match="*:Envelope[not(*:Header)]"> | |
<xsl:copy> | |
<soapenv:Header > | |
<aut:tokenUsuario xmlns:aut="http://caelum.com.br/autorizacao">TOKEN123</aut:tokenUsuario> | |
</soapenv:Header> | |
<xsl:apply-templates select="@*|node()" /> | |
</xsl:copy> | |
</xsl:template> | |
<!-- o template abaixo adiciona o elemento tokenUsuario se o Header já existe --> | |
<xsl:template match="*:Header"> | |
<xsl:copy> | |
<!-- adicione elemento abaixo ao header --> | |
<aut:tokenUsuario xmlns:aut="http://caelum.com.br/autorizacao">TOKEN123</aut:tokenUsuario> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment