开发者

warning: failed to load external entity

开发者 https://www.devze.com 2023-03-25 00:21 出处:网络
I am processing an XML document from within directory A in X (X -> A) using an XSLT stylesheet that uses the document() function to dynamically build a directory path to another XML document in N... t

I am processing an XML document from within directory A in X (X -> A) using an XSLT stylesheet that uses the document() function to dynamically build a directory path to another XML document in N... this part works like a charm.

The XML document in N further needs input from nodes in an XML d开发者_C百科ocument in (Y -> A); when I call my stylesheet, it returns the error below.

warning: failed to load external entity "..

I am explicitly telling my xslt processor to process all my processing instructions relative to the initial XML document NOT the stylesheet by default.

What could I be doing wrong?

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

My XML files are chuncked up and I need to dynamically build node lists.


It turns out I had to explicitly pre-append file:/// to the complete file path of the xml file I was proc


xsltproc : warning: failed to load external entity "-o"

Error:

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

Works:

  • 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 ~]$ 

warning: failed to load external entity

0

精彩评论

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