xml - XSLT 生成不需要的名称空间
问题描述
我有一个这样的xml:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<cm:property-placeholder persistent-id="pot_kodtar_service" update-strategy="reload"/>
...
<bean class="xxxxx.fuse.util.CommonAuthInterceptor" id="authorizationInterceptor">
<property name="methodRolesMap">
<map>
<entry key="xxxElemE1" value="xxxElemE1Role"/>
<entry key="xxxTipusE1" value="xxxTipusE1Role"/>
<entry key="xxxLekerdezE1" value="xxxLekerdezE1Role"/>
<entry key="xxxValtozasE1" value="xxxValtozasE1Role"/>
</map>
</property>
<property name="globalRoles" value="xxxUsers"/>
</bean>
我想在最后一个条目之后附加一个新元素。如果我发现最后一个没有命名空间的元素是这样的:
<xsl:template match="*:map/*:entry[last()]">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<entry key="{$service-name}" value="{$service-name}Role"/>
</xsl:copy>
</xsl:template>
我在输出文档中得到额外的命名空间,如下所示:
<entry key="xxxValtozasE1" value="xxxValtozasE1Role"/> <!-- that is last existing element-->
<entry xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
key="xxxElemKeresE1"
value="xxxElemKeresE1Role"/> <!-- that is newly added element with unwanted namespaces-->
插入的条目包含额外的 xmlns:="" 和 xmlns:xsd="..." 定义。如何消除这些额外的命名空间定义?
谢谢扎梅克
解决方案
在样式表的或根元素上添加xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
和。第一个建议应该将结果元素放在输出命名空间中,第二个建议应该避免输出我想你已经在样式表中声明的输出。exclude-result-prefixes="xsd"
xsl:stylesheet
xsl:transform
xmlns:xsd
推荐阅读
- spring - Spring Boot - 为什么我不能在 RestController 中生成字符串?
- c# - system.argumentexception 列不属于表
- json - 为什么 json.Unmarshal 在 golang 中追加一个新指针后会更改指针值?
- javascript - 使用 Javascript 在 Shiny 应用程序中删除 DataTable 行
- c - 使用带有参数的 Sprintf 就像 İn Vprintf
- python - 如何使用 for 循环为我的数据框中的每一列绘制多个图
- python - 内存泄漏调试python
- python - 使用 python 将多个列从 excel 工作表的 file1 复制到 file2 其他 excel 工作表的其他列/行,使用 pandas 或其他任何东西
- c# - 使用 c# 将 csv 文件中的内容粘贴到 selenium 中的表中
- python - Sqlalchemy 简单查询过滤器不起作用。它返回所有行