开发者

Error on load and loadXML using DOM

I am trying to load an XML file but I get the following errors either I use load(''); or loadXML(); I guess the error is somewhere not in the load, but I can not think what may be. What am I missing here?

the XSLT

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    version="1.0">

    <xsl:template match="files">
        <xsl:variable name="docs">
            <docs>
                <xsl:for-each select="file">
                    <xsl:copy-of select="document(.)"/>
                </xsl:for-each>
            </docs>
        </xsl:variable>

        <xsl:apply-templates select="msxsl:node-set($docs)"/>
    </xsl:template>

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() |开发者_Go百科 @*" />
  </xsl:copy>
</xsl:template>

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


</xsl:stylesheet>


Summary of my comments (now deleted):

While I dont see any loadXML in your example code, the first error message tells you the XML you tried to load is malformed because of what it says. Like Yoshi pointed out, you might be trying to load a URI when loadXML expects an XML String.

The second error message implies that you are using an unknown function in the XPath select expression. libxml/libxslt only supports XPath 1.0. msxsl:node-set($docs) is not a regular xpath function. its not supported.

Try without the namespace, e.g. just node-set. If that doesnt work, replace the msxsl namespace with xmlns:exsl="http://exslt.org/common" in the root element and try with exsl:node-set.

Also see Understanding the node-set() Function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜