如何在带有DTD的XML中包括超链接

时间:2019-07-15 16:01:18

标签: xml xml-namespaces dtd

我正在尝试将超链接从“作者”元素移动到“标题”元素。我无法弄清楚如何使用下面的外部dtd来使此XML有效。

当前,在验证时,我收到此错误:

  元素类型“ frontmatter”的声明中必须

第57行A')'。

最初,XML文件在元素作者中具有指向不同URL的超链接

这是DTD:

<!--
Filename: book.dtd
Created by S. Renko All rights reserved.
-->

<!-- Begin of DTD -->
<!ENTITY % pname "(firstname, middlename?, lastname, (html:a)?)">
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT middlename (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>

<!ELEMENT html:a ANY>
<!ATTLIST html:a 
        href CDATA #IMPLIED
        target CDATA #IMPLIED>

<!ENTITY % frontmatter "(html:img?, html:a?, titlepage*, tableofcontents?, listoffigures?, preface*, foreword*, 
    dedication*, acknowledgment*, errata*, frontispiece*)">

<!ELEMENT html:img  EMPTY>
<!ATTLIST html:img 
        src CDATA #IMPLIED
        style CDATA #IMPLIED
        alt CDATA #IMPLIED>

<!ENTITY % titleinfo "(title | subtitle | author | translator | date | note)*">
<!ELEMENT title (#PCDATA)>
<!ATTLIST title class CDATA #IMPLIED>

<!ELEMENT date (#PCDATA) >

<!ELEMENT author %pname;>

<!ELEMENT book (metadata, frontmatter, body, end)>
<!ATTLIST book 
    xmlns CDATA #FIXED "http://www.steverenko.hostfree.pw/729/"
    xmlns:html CDATA #FIXED "http://www.w3.org/1999/xhtml"> 

<!ELEMENT metadata (dc:title | dc:creator | dc:subject | dc:description | dc:publisher | dc:contributor | dc:date | dc:type | dc:format | dc:identifier | dc:source | dc:language | dc:relation | dc:coverage | dc:rights)*>
<!ATTLIST metadata xmlns:dc CDATA #FIXED "http://purl.org/dc/elements/1.1/"> 
<!ELEMENT dc:title (#PCDATA) >
<!ELEMENT dc:creator (#PCDATA) >
<!ELEMENT dc:subject (#PCDATA) >
<!ELEMENT dc:description (#PCDATA) >
<!ELEMENT dc:publisher (#PCDATA) >
<!ELEMENT dc:contributor (#PCDATA) >
<!ELEMENT dc:date (#PCDATA) >
<!ELEMENT dc:type (#PCDATA) >
<!ELEMENT dc:format (#PCDATA) >
<!ELEMENT dc:identifier (#PCDATA) >
<!ELEMENT dc:source (#PCDATA) >
<!ELEMENT dc:language (#PCDATA) >
<!ELEMENT dc:relation (#PCDATA) >
<!ELEMENT dc:coverage (#PCDATA) >
<!ELEMENT dc:rights (#PCDATA) >

<!ELEMENT frontmatter (%frontmatter;) >
<!ATTLIST frontmatter class CDATA #IMPLIED>

<!ELEMENT titlepage %titleinfo;>
<!ELEMENT body (part | chapter | subchapter | paragraph | poem | note)* >
<!ELEMENT part (frontmatter?, body, end?, note*)>
<!ELEMENT chapter ((frontmatter? | chapterfrontmatter?), body, end?, note*)>
<!ELEMENT subchapter (paragraph | note)*>

<!ELEMENT paragraph (#PCDATA  | poem | reference | emp | ital | quote | html:span)*>
<!ATTLIST paragraph class CDATA #IMPLIED>

<!ELEMENT html:span (#PCDATA)>
<!ATTLIST html:span style CDATA #IMPLIED>

<!ELEMENT poem (line)*>
<!ELEMENT line (#PCDATA)>
<!ELEMENT emp (#PCDATA)>
<!ELEMENT ital (#PCDATA)>
<!ELEMENT quote (#PCDATA)>
<!ELEMENT reference (#PCDATA)>
<!ATTLIST reference     type    (footnote-num | footnote-ref)   #REQUIRED
                        ref     ID                              #IMPLIED>

<!ELEMENT note (paragraph*)>
<!ATTLIST note      class   CDATA   #REQUIRED
                    id      IDREF   #IMPLIED>

<!ELEMENT end (appendix | bibliography | endnotes | glossary | index | note )*>

这是XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="SR-SciFi.css"?>
<!DOCTYPE book SYSTEM "book.dtd">
<!-- Use html:span for display using CSS -->
<!-- We can ignore all html:span elements if we use the same doc with XSLT -->
<book xmlns="http://www.steverenko.hostfree.pw/729/" xmlns:html="http://www.w3.org/1999/xhtml">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
        <dc:title>The Time Machine</dc:title>
        <dc:creator>Wells, H. G. (Herbert George), 1866-1946 </dc:creator>
        <dc:subject>Science fiction</dc:subject>
        <dc:subject>PR</dc:subject>
        <dc:language>eng</dc:language>
        <dc:description> </dc:description>
        <dc:publisher> www.kwongbor.net</dc:publisher>
        <dc:date>2019-07-15</dc:date>
        <dc:type>World Wide Web resource</dc:type>
        <dc:type>electronic resource</dc:type>
        <dc:type>text/xml</dc:type>
        <dc:identifier></dc:identifier>
        <dc:source>http://www.steverenko.hostfree.pw/729/</dc:source>
        <dc:relation>K.B.Ng's GSLIS 729</dc:relation>
        <dc:relation>Browser with XML parser</dc:relation>
        <dc:relation>Mode of access: Internet via World Wide Web</dc:relation>
        <dc:coverage> </dc:coverage>
        <dc:rights>The only legal and authorized use of these files is for the nonprofit production. 
                    The copyright for these files is the sole property of the original owner.  </dc:rights>
        <dc:rights>Access limited to students of GSLIS 729.</dc:rights>
    </metadata>
    <frontmatter>
        <html:img src="timemachinebookcover.jpg" style="float: left;"/>
        <titlepage>
            <title class="book"><html:a href= "http://en.wikipedia.org/wiki/H._G._Wells" target="_blank">
   The Time Machine</html:a>
  </title>
            <author>
                <firstname> Herbert </firstname>
                <middlename> George </middlename>
                <lastname> Wells </lastname>
                <html:a href="HGWellsCat.v03.xml">

                <html:img src="HGWells1922.small.gif" alt="Click to see our catalog of books written by the same author." style="margin-left: 20px;"/>
                </html:a>
            </author>
            <date> 1895 </date>
        </titlepage>
    </frontmatter>
    <body>
        <chapter>
            <frontmatter class="chapter">
                <titlepage>
                    <title class="chapter"> I </title>
                </titlepage>
            </frontmatter>

“ Time Machine”标题元素应该是指向所引用的Wiki页面的超链接。

目前,我知道了     元素类型“ frontmatter”的声明中需要“ 57:37 A')'。

我相信那条线

  <title class="book"><html:a href= "http://en.wikipedia.org/wiki/H._G._Wells" target="_blank">
   The Time Machine</html:a>
  </title>

是扔掉整个事情的原因,但我不知道如何在符合上述DTD的同时在title元素内允许html:a

0 个答案:

没有答案