변수에 soap : Header 요소의 자식 요소를 모두 복사하려고 시도하고 PricingRequest 빈 네임 스페이스 (xmlns = "http : //www.ama .net ") xml의 PricingRequest 부분 만 출력합니다. PricingRequest 빈 네임 스페이스를 제거하고 적절한 출력을 얻을 수 있지만 soap : Header 자식 요소를 변수에 저장할 수 없다면 soap : Header의 자식 요소를 변수에 복사 할 수 있습니까?자식 노드 네임 스페이스를 제거하고 다른 노드를 변수로 복사
입력 XML :
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap ="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns="http://www.ama.net/1axml-msg/schema/msg-header-1_0.xsd">
<MessageHeader ResponseRequested="true" version="1.0" Terminate="true" Reverse="true" id="09B5581A" soap:mustUnderstand="1">
<From>1ASI</From>
<To>1ASRINSAIG</To>
<TimeStamp>
<GenerationTime>2014-10-22T12:41:38Z</GenerationTime>
</TimeStamp>
</MessageHeader>
</soap:Header>
<soap:Body>
<PricingRequest xmlns="http://www.ama.net">
<originatorSection>
<deliverySystem>
<companyId>1A</companyId>
<cityCode>MUC</cityCode>
</deliverySystem>
</originatorSection>
</PricingRequest>
</soap:Body>
</soap:Envelope>
XSLT : 변수에 헤더 :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://www.ama.net" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- <xsl:template match="/*[local-name()='Envelope']">
<xsl:variable name="SOAPHeader" select="/soap:Header/node()" />
<xsl:text> MessageHeader INFO:<xsl:copy-of select="$SOAPHeader"/> </xsl:text>
</xsl:template> -->
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="*[not(ancestor-or-self::x:PricingRequest)]">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
비누를 복사 할 수 OUTPUT을 기대하지만 점점
<PricingRequest>
<originatorSection>
<deliverySystem>
<companyId>1A</companyId>
<cityCode>MUC</cityCode>
</deliverySystem>
</originatorSection>
</PricingRequest>
: 헤더 * "하지만 당신은 비누의 자손 인 몸을 보여주고 있습니다. –
안녕 마이클, 제 질문을 찾아 주셔서 고맙습니다. 위의 xslt는 내가 찾고있는 XML 출력을 얻을 수 있으며 로깅 목적을 위해 모든 요소와 속성을 soap : Header 내부에 인쇄해야합니다. 내 xslt 보면, 주석 코드에서 무엇을하려고하는지 볼 수 있습니다. 나는 비누 : 헤더와 일치시킬 수 없으며 변수에 내용을 복사한다. – sarma