加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

创建xmlns:xsi命名空间和属性

发布时间:2020-12-16 07:42:49 所属栏目:百科 来源:网络整理
导读:我想创建以下元素: 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
我想创建以下元素:
<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"/>

然后它创建这样的soemthing:

<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命名空间.

我刚刚做了模板比赛,只是为了测试.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读