저는 XSL에 익숙하며 XSL에 대한 약간의 도움이 필요합니다. 네임 스페이스 SPR에 정의 된 문자열을 다른 문자열로 대체해야하지만, somereason에 대해서는 XSL does not work, 일부 사람이 나를 잘못 빠져 나올 수있게 도와 줬어.이름 공간에 정의 된 문자열을 바꾸기
XML :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://xyz.com/xsd">
<soapenv:Header>
<xsd:myHeader>
<!--Optional:-->
<APP_ID>APP_ID</APP_ID>
</xsd:myHeader>
</soapenv:Header>
<soapenv:Body>
<tns:SPR xmlns:tns="http://xyz.com/xsd">
<Info>
<System>
<id>id</id>
<sourceSystemName>sourceSystemName</sourceSystemName>
</System>
<Type>transmissionType</Type>
<Id>encounterId</Id>
</Info>
</tns:SPR>
</soapenv:Body>
</soapenv:Envelope>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/Header/Body/SubmitPreClaimRequest/*[namespace-uri(.)='']">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="/Header/Body/SPR" />
<xsl:with-param name="replace" select="SPR" />
<xsl:with-param name="by" select="ONE" />
</xsl:call-template>
</xsl:for-each>
<xsl:apply-templates />
</xsl:template>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Result with my XSL:
<?xml version="1.0" encoding="UTF-16"?>APP_IDidsourceSystemNametransmissionTypeencounterId
EXPECTED Result:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://xyz.com/xsd">
<soapenv:Header>
<xsd:myHeader>
<!--Optional:-->
<APP_ID>APP_ID</APP_ID>
</xsd:myHeader>
</soapenv:Header>
<soapenv:Body>
**<tns:ONE xmlns:tns="http://xyz.com/xsd">**
<Info>
<System>
<id>id</id>
<sourceSystemName>sourceSystemName</sourceSystemName>
</System>
<Type>transmissionType</Type>
<Id>encounterId</Id>
</Info>
**</tns:ONE>**
</soapenv:Body>
</soapenv:Envelop
좋은 질문, +1. 가장 근본적이고 강력한 XSLT 디자인 패턴을 기반으로하는 완전하고, 쉽고 간단한 솔루션 인 정체성 규칙 재정의 내 대답을 확인하십시오. –
또한 광범위한 설명을 추가했습니다. –