警告:无法加载外部实体

时间:2011-08-02 21:33:51

标签: xslt xslt-1.0

我正在使用XSLT样式表从X(X - > A)中的目录A内处理XML文档,该样式表使用 document()函数动态构建到另一个XML文档的目录路径在N ...这部分就像一个魅力。

N中的XML文档还需要来自(Y - > A)中的XML文档中的节点的输入;当我调用我的样式表时,它会返回以下错误。

警告:无法加载外部实体“..

我明确告诉我的xslt处理器默认处理相对于初始XML文档 NOT 样式表的所有处理指令。

我可能做错了什么?

dir/
├── X
│   ├── A
│   │   ├── N
│   │   ├── O
│   │   ├── P
├── Y
│   ├── A
│   ├── B
│   ├── C
│   ├── D
│   ├── E
│   └── F

我的XML文件被重新启动,我需要动态构建节点列表。

2 个答案:

答案 0 :(得分:3)

事实证明我必须显式地将file:///预先附加到我是proc的xml文件的完整文件路径

答案 1 :(得分:0)

xsltproc:警告:无法加载外部实体“ -o”

错误:

  • xsltproc a.xsl a.xml -o a.html

作品:

  • xsltproc -o a.html a.xsl a.xml
  • xsltproc a.xsl a.xml > a.html

[victoria@victoria ~]$ which xsltproc
  /usr/bin/xsltproc

[victoria@victoria ~]$ xsltproc --version
  Using libxml 20910, libxslt 10134-GITv1.1.34 and libexslt 820
  xsltproc was compiled against libxml 20910, libxslt 10134 and libexslt 820
  libxslt 10134 was compiled against libxml 20910
  libexslt 820 was compiled against libxml 20910

[victoria@victoria ~]$ xsltproc a.xsl a.xml -o a.html
  warning: failed to load external entity "-o"
  unable to parse -o

[victoria@victoria xslt_test]$ xsltproc | head -n1
    Usage: xsltproc [options] stylesheet file [file ...]

[victoria@victoria ~]$ xsltproc -o a.html a.xsl a.xml
[victoria@victoria ~]$ ## command completed; HTML page looks fine ...

[victoria@victoria ~]$ cat ~/a.xsl
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
  <html> 
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th style="text-align:left">Title</th>
        <th style="text-align:left">Artist</th>
      </tr>
      <xsl:for-each select="catalog/cd">
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>

[victoria@victoria ~]$ cat ~/a.xml
  <?xml version="1.0" encoding="UTF-8"?>

  <!-- https://www.w3schools.com/xml/xsl_intro.asp -->
  <!-- https://www.w3schools.com/xml/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog -->

  <catalog>
    <cd>
      <title>Empire Burlesque</title>
      <artist>Bob Dylan</artist>
      <country>USA</country>
      <company>Columbia</company>
      <price>10.90</price>
      <year>1985</year>
    </cd>
    <cd>
      <title>Hide your heart</title>
      <artist>Bonnie Tyler</artist>
      <country>UK</country>
      <company>CBS Records</company>
      <price>9.90</price>
      <year>1988</year>
    </cd>
  </catalog>

[victoria@victoria ~]$ 

enter image description here