У меня есть следующие полезные данные в XML. Я хочу включить пространство имен для каждого тега. Я не могу использовать Найти и заменить для (Найти '<' и заменить '<h2> XML Payload :: -
<ROWSET> <ROW> <RECEIPT_METHOD_ID>-1</RECEIPT_METHOD_ID> <CREATED_BY>SEED_DATA_FROM_APPLICATION</CREATED_BY> <CREATION_DATE>2018-12-14T18:10:42.257+00:00</CREATION_DATE> <LAST_UPDATED_BY>abcd</LAST_UPDATED_BY> <LAST_UPDATE_DATE>2019-10-18T09:27:51.159+00:00</LAST_UPDATE_DATE> <NAME>ORA_AP/AR Netting</NAME> <RECEIPT_CLASS_ID>-1</RECEIPT_CLASS_ID> <START_DATE>1952-01-01T00:00:00.000+00:00</START_DATE> <AUTO_PRINT_PROGRAM_ID/> <AUTO_TRANS_PROGRAM_ID/> <END_DATE>null</END_DATE>
Я хочу это в следующем формате :: --
<nstrgdfl:ROWSET> <nstrgdfl:ROW> <nstrgdfl:RECEIPT_METHOD_ID>-1</nstrgdfl:RECEIPT_METHOD_ID> <nstrgdfl:CREATED_BY>SEED_DATA_FROM_APPLICATION</nstrgdfl:CREATED_BY> <nstrgdfl:CREATION_DATE>2018-12-14T18:10:42.257+00:00</nstrgdfl:CREATION_DATE> <nstrgdfl:LAST_UPDATED_BY>abcd</nstrgdfl:LAST_UPDATED_BY> <nstrgdfl:LAST_UPDATE_DATE>2019-10-18T09:27:51.159+00:00</nstrgdfl:LAST_UPDATE_DATE> <nstrgdfl:NAME>ORA_AP/AR Netting</nstrgdfl:NAME> <nstrgdfl:RECEIPT_CLASS_ID>-1</nstrgdfl:RECEIPT_CLASS_ID> <nstrgdfl:START_DATE>1952-01-01T00:00:00.000+00:00</nstrgdfl:START_DATE> <nstrgdfl:AUTO_PRINT_PROGRAM_ID/> <nstrgdfl:AUTO_TRANS_PROGRAM_ID/> <nstrgdfl:END_DATE>null</nstrgdfl:END_DATE>
*
Ниже приводится текущее используемое сопоставление XSL :: Обратите внимание, что мой входной XML присутствует в переменной $ Base64DecodedData_Report (/.....) XSL MApping: -
<?xml version = '1.0' encoding = 'UTF-8'?> <xsl:stylesheet version="2.0" xml:id="id_1" xmlns:nstrgdfl="http://www.example.org" xmlns:nstrgmpr="http://xmlns.oracle.com/cloud/adapter/REST/CallCommonERPQuery_REQUEST/types" xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://xmlns.oracle.com/cloud/adapter/REST/CallCommonERPQuery_REQUEST" xmlns:ns2="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/CallCommonERPQuery" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes=" oraext xsd xp20 ora oracle-xsl-mapper xsi fn xsl ignore01" xmlns:ignore01="http://www.oracle.com/XSL/Transform/java" ignore01:ignorexmlids="true" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:nsmpr0="http://xmlns.oracle.com/oxp/service/PublicReportService" xmlns:nsmpr1="http://xmlns.oracle.com/types/CallReportServiceERP/OutboundSOAPRequestDocument"> <oracle-xsl-mapper:schema xml:id="id_2"> <!--SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY.--> <oracle-xsl-mapper:mapSources xml:id="id_3"> <oracle-xsl-mapper:source type="WSDL" xml:id="id_4"> <oracle-xsl-mapper:schema location="../../application_8/outbound_9/resourcegroup_10/CallCommonERPQuery_REQUEST.wsdl" xml:id="id_5"/> <oracle-xsl-mapper:rootElement name="execute" namespace="http://xmlns.oracle.com/cloud/adapter/REST/CallCommonERPQuery_REQUEST/types" xml:id="id_6"/> </oracle-xsl-mapper:source> </oracle-xsl-mapper:mapSources> <oracle-xsl-mapper:mapTargets xml:id="id_7"> <oracle-xsl-mapper:target type="WSDL" xml:id="id_8"> <oracle-xsl-mapper:schema location="../../application_8/outbound_9/resourcegroup_10/CallCommonERPQuery_REQUEST.wsdl" xml:id="id_9"/> <oracle-xsl-mapper:rootElement name="executeResponse" namespace="http://xmlns.oracle.com/cloud/adapter/REST/CallCommonERPQuery_REQUEST/types" xml:id="id_10"/> </oracle-xsl-mapper:target> </oracle-xsl-mapper:mapTargets> <!--GENERATED BY ORACLE XSL MAPPER 12.1.2.0.0--> </oracle-xsl-mapper:schema> <!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE--> <xsl:param name="Status" xml:id="id_23"/> <xsl:param name="Base64DecodedData_Report" xml:id="id_38"/> <xsl:template match="/" xml:id="id_11"> <nstrgmpr:executeResponse xml:id="id_12"> <nstrgdfl:Response xml:id="id_27"> <nstrgdfl:Status xml:id="id_28"> <xsl:value-of select="$Status" xml:id="id_29"/> </nstrgdfl:Status> <nstrgdfl:QueryOutput xml:id="id_44"> <xsl:copy-of select="oraext:parseEscapedXML($Base64DecodedData_Report)" xml:id="id_45"/> </nstrgdfl:QueryOutput> </nstrgdfl:Response> </nstrgmpr:executeResponse> </xsl:template> </xsl:stylesheet>
Вы можете использовать это так:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nstrgdfl="http://www.url.com" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@* | node() except *"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:element name="{concat('nstrgdfl:',name())}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> </xsl:stylesheet>
см. Ссылку: https://xsltfiddle.liberty -development.net / bFWR5E7