gpt4 book ai didi

xml - 创建 xmlns :xsi namespace and attribute

转载 作者:数据小太阳 更新时间:2023-10-29 01:42:19 24 4
gpt4 key购买 nike

我想创建以下元素:

<exercises xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mySchema.xsd">

如果我使用这样的东西:

<xsl:element name="excercises">
<xsl:attribute name="xmlns:xsi" namespace="http://www.w3.org/2001/XMLSchema-instance"/>

然后它创建这样的东西:

<excercises xp_0:xsi="" xmlns:xp_0="http://www.w3.org/2001/XMLSchema-instance">

这看起来不像我想要的...

最佳答案

请尝试以下操作:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="@* | node()">
<xsl:apply-templates select="xml"></xsl:apply-templates>
</xsl:template>

<xsl:template match="xml">
<xsl:element name="exercises">
<xsl:attribute name="xsi:noNamespaceSchemaLocation">mySchema.xsd</xsl:attribute>
some value
</xsl:element>
</xsl:template>
</xsl:stylesheet>

关键问题是在声明中声明 xsi 命名空间。

我刚刚编写了模板匹配只是为了测试。

关于xml - 创建 xmlns :xsi namespace and attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/424148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com