我正在尝试转换 xml:
<servicioSDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" facade="GestionEstadosSolicitudEspecifico" xmlns="http://new.webservice.namespace">
<entrada xmlns="">
<IdSubscription>7daa07b5-348c-463b-ab09-d6fb0e25dc53</IdSubscription>
<BusinessProcessCode>Expediente Digital</BusinessProcessCode>
<ParamResponses>
<ParamResponse>
<Name>TIPODOCUMENTO</Name>
<ValParam>DOCGEN_PO_ED</ValParam>
</ParamResponse>
<ParamResponse>
<Name>GN_ID</Name>
<ValParam>KFX001_2105</ValParam>
</ParamResponse>
<ParamResponse>
<Name>NUM_PERSONA_CLI</Name>
<ValParam>F8469</ValParam>
<ValParam>F8470</ValParam>
<ValParam>F8471</ValParam>
</ParamResponse>
<ParamResponse>
<Name>GN_VALIDITYDATE</Name>
<ValParam>9999-12-31</ValParam>
</ParamResponse>
<ParamResponse>
<Name>CONT_PARTENON</Name>
<ValParam>00490075442115807771</ValParam>
</ParamResponse>
<ParamResponse>
<Name>ID_SOLICITUD</Name>
<ValParam>00490075000003590200001</ValParam>
</ParamResponse>
<ParamResponse>
<Name>GN_CREATIONDATE</Name>
<ValParam>2013-5-21</ValParam>
</ParamResponse>
</ParamResponses>
</entrada>
</servicioSDD>
使用 xslt:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes=''
>
<xsl:template match="/">
<entrada >
<xsl:for-each select="servicioSDD/entrada/ParamResponses/ParamResponse">
<xsl:if test="Name='TIPODOCUMENTO'">
<TIPODOCUMENTO><xsl:value-of select="ValParam"/></TIPODOCUMENTO>
</xsl:if>
<xsl:if test="Name='GN_ID'">
<GN_ID><xsl:value-of select="ValParam"/></GN_ID>
</xsl:if>
<xsl:if test="Name='CONT_PARTENON'">
<xsl:variable name="contrato" select="ValParam"/>
<CONT_PARTENON>
<CENTRO>
<EMPRESA><xsl:value-of select="substring($contrato,1,4)"/></EMPRESA>
<CENTRO><xsl:value-of select="substring($contrato,5,4)"/></CENTRO>
</CENTRO>
<PRODUCTO><xsl:value-of select="substring($contrato,9,3)"/></PRODUCTO>
<NUMERO_DE_CONTRATO><xsl:value-of select="substring($contrato,12,7)"/></NUMERO_DE_CONTRATO>
</CONT_PARTENON>
</xsl:if>
<xsl:if test="Name='ID_SOLICITUD'">
<xsl:variable name="solicitud" select="ValParam"/>
<ID_SOLICITUD>
<CODIGO_DE_SOLICITUD><xsl:value-of select="substring($solicitud,21)"/></CODIGO_DE_SOLICITUD>
<ID_CASO_PN>
<CODIGO_DE_CASO><xsl:value-of select="substring($solicitud,9,10)"/></CODIGO_DE_CASO>
<CENTRO>
<EMPRESA><xsl:value-of select="substring($solicitud,1,4)"/></EMPRESA>
<CENTRO><xsl:value-of select="substring($solicitud,5,4)"/></CENTRO>
</CENTRO>
<VERSION><xsl:value-of select="substring($solicitud,19,2)"/></VERSION>
</ID_CASO_PN>
</ID_SOLICITUD>
</xsl:if>
<xsl:if test="Name='GN_CREATIONDATE'">
<xsl:variable name="Cdate" select="ValParam"/>
<GN_CREATIONDATE><xsl:value-of select="concat(substring($Cdate,9,2),concat(concat('-',substring($Cdate,6,2)), concat('-',substring($Cdate,1,4))))"/></GN_CREATIONDATE>
</xsl:if>
<xsl:if test="Name='GN_VALIDITYDATE'">
<xsl:variable name="Vdate" select="ValParam"/>
<GN_VALIDITYDATE><xsl:value-of select="concat(substring($Vdate,9,2),concat(concat('-',substring($Vdate,6,2)), concat('-',substring($Vdate,1,4))))"/></GN_VALIDITYDATE>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="servicioSDD/entrada/ParamResponses/ParamResponse[Name='NUM_PERSONA_CLI']">
<listaPersonaCliente>
<xsl:for-each select="ValParam">
<NUM_PERSONA_CLI>
<xsl:variable name='cliente' select="."/>
<CODIGO_DE_PERSONA><xsl:value-of select="substring($cliente,2)"/></CODIGO_DE_PERSONA>
<TIPO_DE_PERSONA><xsl:value-of select="substring($cliente,1,1)"/></TIPO_DE_PERSONA>
</NUM_PERSONA_CLI>
</xsl:for-each>
</listaPersonaCliente>
</xsl:for-each>
</entrada>
</xsl:template>
</xsl:stylesheet>
我得到的结果是:
<?xml version="1.0" encoding="UTF-8"?><entrada/>
如果我删除 xml: 转换完成没有问题,但我无法控制我的服务的 xml 格式的到来
非常感谢您