【发布时间】:2017-12-16 04:04:55
【问题描述】:
我需要用所有东西、每个节点上的命名空间等生成这个 xml
<bdo_fosfec:RegistrosPagosElement xsi:type="bdo_fosfec:RegistrosPagos"
xmlns:bdo_fosfec="http://asocajas.app.com/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<registro54 xsi:type="bdo_fosfec:Registro54">
<registro82 xsi:type="bdo_fosfec:Registro82">
<C512>39756656</C512>
<C614>YAXMINNI</C614>
</registro82>
</registro54>
<registro54 xsi:type="bdo_fosfec:Registro54">
<registro82 xsi:type="bdo_fosfec:Registro82">
<C512>79374740</C512>
<C614>VICTOR</C614>
</registro82>
</registro54>
</bdo_fosfec:RegistrosPagosElement>
我构建了一个 XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<bdo_fosfec:RegistrosPagosElement xsi:type="bdo_fosfec:RegistrosPagos" xmlns:bdo_fosfec="http://asocajas.app.com/example" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:apply-templates select="registro54"/>
</bdo_fosfec:RegistrosPagosElement>
</xsl:template>
<!--TEMPLATE REGISTRO 54-->
<xsl:template match="registro54">
<registro54 xsi:type="bdo_fosfec:Registro54">
<registro82 xsi:type="bdo_fosfec:Registro82">
<C512><xsl:value-of select="C512"/></C512>
<C614><xsl:value-of select="C614"/></C614>
</registro82>
</registro54>
</xsl:template>
</xsl:stylesheet>
但是当我使用 XSLT 转换 myxml 时,result xml 并不像预期的那样
结果:
<?xml version="1.0" encoding="utf-8"?>
<bdo_fosfec:RegistrosPagosElement xsi:type="bdo_fosfec:RegistrosPagos" xmlns:bdo_fosfec="http://asocajas.app.com/example" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
myxml
<?xml version="1.0" encoding="utf-8"?>
<bdo_fosfec_x003A_RegistrosPagosElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<registro54>
<registro82>
<C512>123456789</C512>
<C614>Miguel</C614>
</registro82>
</registro54>
<registro54>
<registro82>
<C512>1234567890</C512>
<C614>Jerónimo</C614>
</registro82>
</registro54>
</bdo_fosfec_x003A_RegistrosPagosElement>
我不知道我做错了什么,我尝试删除名称空间 xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: type = "bdo_fosfec: RegistersPages" xmlns: bdo_fosfec = "http: //asocajas. hp.com/bdo_fosfec ”的样式表,但它会产生错误,我也尝试不使用“模板”,结果接近所需的,但我希望不一样
谢谢
【问题讨论】: