Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops xslt循环属性因命名空间属性而失败_Loops_Xslt_Namespaces_Attributes - Fatal编程技术网

Loops xslt循环属性因命名空间属性而失败

Loops xslt循环属性因命名空间属性而失败,loops,xslt,namespaces,attributes,Loops,Xslt,Namespaces,Attributes,我将属性转换为表, 但我不知道会设置哪些属性, 所以我得到了以下解决方案: <simpletable spectitle="Chapter Attribute"> <sthead> <stentry>Name</stentry> <stentry>Wert</st

我将属性转换为表, 但我不知道会设置哪些属性, 所以我得到了以下解决方案:

                <simpletable  spectitle="Chapter Attribute">
                    <sthead>
                        <stentry>Name</stentry>
                        <stentry>Wert</stentry>
                    </sthead>
                    <xsl:apply-templates select="@*"/>
                    <xsl:apply-templates select="Head/@*"/>
                </simpletable>

<!-- ********************* Chapter Attribute -> simpleTable....strow ************************************************************************************** -->
<xsl:template match="Chapter/@*|Head/@*">
    <xsl:choose>
        <xsl:when test="string(.)">
            <strow>
                <stentry>
                    <xsl:value-of select="local-name(.)"/>
                </stentry>
                <stentry>
                    <xsl:value-of select="."/>
                </stentry>
            </strow>
        </xsl:when>
    </xsl:choose>
</xsl:template>

名称
韦特
以下是我要处理的XML:

<Chapter title="Information" termpool="" nodeid="DE-123" xmltag="Chapter" 
 status="" id="" language="" version="">
<Head UniqueID="DE-234" xmlns:axf="http://www.antennahouse.com/names
         /XSL/Extensions">Information</Head>

问询处
这就是结果

<strow>
    <stentry>title</stentry>
    <stentry>Information</stentry>
</strow>
<strow>
    <stentry>nodeid</stentry>
    <stentry>DE-123</stentry>
</strow>
<strow>
    <stentry>xmltag</stentry>
    <stentry>Chapter</stentry>
</strow>
<strow>
    <stentry>UniqueID</stentry>
    <stentry>DE-234</stentry>
</strow>

标题
问询处
诺代德
DE-123
xmltag
章
独一无二的
DE-234
对于>来说,它可以正常工作,但是对于>来说,它不能识别xmlns:axf (或者xmlns:axf有一个变量集)

希望有人能给我一个提示,如何使用@*
感谢Jochen,在XPath使用的XDM数据模型中,名称空间和属性是完全不同的。属性轴
@*
为您提供了所需名称空间的属性,名称空间轴
名称空间::*


注意,这将为您提供元素范围内的所有名称空间,而不仅仅是在该元素上声明的名称空间。如果您确实想要元素上存在而父元素上不存在的名称空间,那么逻辑将取决于您使用的XSLT版本,您还没有告诉我们。

谢谢您的回答,但它会出错。我使用2.0版。我想谢谢你的回答,但有错误。我使用2.0版。我试过了,但都失败了。他不是接受者。我想我理解错了。我的xmlspy说xpath,名称空间xmlns是未定义的,实际上,它没有在我的xml顶部的tge中声明,也许这会导致问题:我告诉过你使用
名称空间:*
,那么你为什么要尝试使用
xmlns::@*
名称空间:@*
?另外,请不要只键入在SO答案中找到的代码,而不先阅读参考书,以便理解它的实际含义。