0

I'm trying to link these two files so I can display the attribute and elements already in the code (@name and callNo.) For some reason, these files aren't linking even though I've checked the file spellings and all. If I try to run the XSL file, the page won't display the attribute/element I'm trying to retrieve. There is no error as far as I know by the way.

Question2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Question2.xsl"?>
<!DOCTYPE patron [
<!ELEMENT patron (item*)>
<!ATTLIST patron name CDATA #REQUIRED>
<!ELEMENT item (title,authors,callNo,due)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT authors (#PCDATA)>
<!ELEMENT callNo (#PCDATA)>
<!ELEMENT due (#PCDATA)>
]>
<patron name="John Smith">
<item>
<title>Wireless network security</title>
<authors>T. Wrightson</authors>
<callNo>212.12/56</callNo>
<due>25-12-2016</due>
</item>
<item>
<title>Analysis</title>
<authors>T. Tao</authors>
<callNo>515/305</callNo>
<due>23-12-2016</due>
</item>
<item>
<title>The art of computer programming</title>
<authors>D.E. Knuth</authors>
<callNo>005.1/300</callNo>
<due>25-11-2016</due>
</item>
<item>
<title>Python for dummies</title>
<authors>S. Maruch and A. Ranum</authors>
<callNo>145.3/157</callNo>
<due>01-10-2016</due>
</item>
</patron>

Question2.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/patron">
  <html>
     <head>
        <title>Question2</title>
     </head>
     <body>
        <h1>
           <xsl:text>Patron record:</xsl:text>
           <xsl:value-of select="@name" />
        </h1>
        <font size="6" color="green">
           <xsl:value-of select="callNo" />
        </font>
     </body>
  </html>
 </xsl:template>
</xsl:stylesheet>
Vikrant
  • 4,920
  • 17
  • 48
  • 72
John DOe
  • 69
  • 1
  • 1
  • 7
  • Why do you copy your question? You asked a [nearly identical question here](https://stackoverflow.com/q/58080389/1305969). – zx485 Sep 24 '19 at 22:23
  • Wasn't sure if I would get an answer there anymore. – John DOe Sep 24 '19 at 22:23
  • Unfortunately, you behaviour is against StackOverflow's rules. I don't know the answer to your question, but maybe [this SO link](https://stackoverflow.com/q/3420513/1305969) will help you. – zx485 Sep 24 '19 at 22:26
  • I deleted the other one. – John DOe Sep 24 '19 at 22:27
  • Did the link help you? – zx485 Sep 24 '19 at 22:28
  • I don't really understand it but I can't get it working on any browser so I assumed it was something to do with my code. I suppose it could just be the browser, but I have no idea how to work around that ahah. – John DOe Sep 24 '19 at 22:33

1 Answers1

0

check this code:-

<xsl:value-of select="callNo" />
              to
<xsl:value-of select="item/callNo" />
Ajeet Singh
  • 1,056
  • 1
  • 6
  • 21