그래서 SOAP 문서의 본문에있는 모든 요소를 XSLT를 사용하여 XML로 변환 (추출)하려고합니다. 여기에 (완전한) 내 SOAP 문서SOAP에서 XSLT를 사용하는 XML
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="dealercode.xsl"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://www.somedomain.com/">
<LogonID></LogonID>
<Password></Password>
</AuthHeader>
</soap:Header>
<soap:Body>
<getDealerCodeById xmlns="http://www.somedomain.com/">
<BrokerCode>{ssQuoterBrokerCode(app_id)}</BrokerCode>
<IDNumber>{dealerCode}</IDNumber>
</getDealerCodeById>
</soap:Body>
</soap:Envelope>
그리고 여기 내 XSLT 시트의입니다.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<?xml-stylesheet type="text/xsl" href="dealercode2soap.xsl"?>
<xsl:template match="/*">
<xsl:value-of select="soap:Body/s:getDealerCodeById"
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
xmlns:s="http://somedomainname/" />
</xsl:stylesheet>
그러나 출력은 내가 원하는 것이 아니다. 그것은 여전히 "soap : Body"엘리먼트 내에서 내용을 제공하는 대신 전체 SOAP 문서를 파싱하고 "해결되지 않은 네임 스페이스 프리픽스 비누"에 대한 경고를받습니다.
어디서 잘못 되었나요?
편집 : 다른 코드 블록을 사용하여 작동하도록했습니다. 그것은 지금 내 브라우저에서 본문 섹션의 내용을 출력
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns ="http://www.somedomainename.com">
<xsl:template match="/">
<xsl:apply-templates select="soap:Envelope/soap:Body/*"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
아래를 참조하십시오. 필자가 깨닫은 또 다른 가장 중요한 사실은 서버 측에서 포맷팅이 이루어졌지만 당시 서버에 액세스 할 수 없었기 때문에 코드가 작동하는지 여부를 알 수 없었습니다. 이것은 분명히 전체 시간을 일하는 내가 찾던 원하는 출력 (입니다. 당신은 당신의 XSLT에서
soap
네임 스페이스를 선언하지 않았기 때문에 당신은 "
해결되지 않은 네임 스페이스 접두사 비누"에 대한 경고를 받고
<?xml version="1.0" encoding="UTF-8"?>
<getDealerCodeById xmlns="http:///" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<BrokerCode>{ssQuoterBrokerCode(app_id)}</BrokerCode>
<IDNumber>{dealerCode}</IDNumber>
</getDealerCodeById>
도움 Mads에게 감사하지만 작동하지 않는 것 같습니다. 나는 네임 스페이스를 조언했다 (기본적으로 위의 코드를 복사했다.) - 다른 생각은 무엇입니까 ?? – Boyds
그게 효과가있다. 테스트를 통해 doc (유효한 XML이되도록 문서 요소를 만든 후)을 테스트합니다. 유형 -o 또는 다른 네임 스페이스가 혼합되어있을 수 있습니다. 입력 XML 및 XSLT에 대한보다 완벽한 예를 게시 할 수 있습니까? –
비누 네임 스페이스가 선언되지 않은 것에 대해 메모를 다시 읽고 보았습니다. 나는 나의 대답을 업데이트했다. XPath에서 XSLT를 사용할 수 있으려면 XSLT에 모든 네임 스페이스를 선언해야합니다. –