⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jaxpsax7.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
ELEMENT: &lt;slideshow&nbsp;&nbsp;ATTR: ...&gt;<code class="cCodeBold">IGNORABLEIGNORABLE</code>PROCESS: ...<code class="cCodeBold">IGNORABLEIGNORABLE</code>&nbsp;&nbsp;ELEMENT: &lt;slide&nbsp;&nbsp;&nbsp;&nbsp;ATTR: ...&nbsp;&nbsp;&gt;&nbsp;&nbsp;<code class="cCodeBold">IGNORABLE</code>&nbsp;&nbsp;&nbsp;&nbsp;ELEMENT: &lt;title&gt;&nbsp;&nbsp;&nbsp;&nbsp;CHARS:   Wake up to ...&nbsp;&nbsp;&nbsp;&nbsp;END_ELM: &lt;/title&gt;&nbsp;&nbsp;<code class="cCodeBold">IGNORABLE</code>&nbsp;&nbsp;END_ELM: &lt;/slide&gt;<code class="cCodeBold">IGNORABLEIGNORABLE</code>&nbsp;&nbsp;ELEMENT: &lt;slide&nbsp;&nbsp;&nbsp;&nbsp;ATTR: ...&nbsp;&nbsp;&gt;&nbsp;&nbsp;...<a name="wp64996"> </a></pre></div><a name="wp64997"> </a><p class="pBody">Here, it is apparent that the ignorableWhitespace is being invoked before and after comments and slide elements, where characters was being invoked before there was a DTD. </p><a name="wp64999"> </a><h3 class="pHeading2">Cleanup</h3><a name="wp65000"> </a><p class="pBody">Now that you have seen ignorable whitespace echoed, remove that code from your version of the Echo program--you won't be needing it any more in the exercises ahead. </p><hr><a name="wp65001"> </a><p class="pNote">Note: That change has been made in <code class="cCode"><a  href="../examples/jaxp/sax/samples/Echo09.java" target="_blank">Echo09.java</a></code>. </p><hr><a name="wp65008"> </a><h3 class="pHeading2">Empty Elements, Revisited</h3><a name="wp65009"> </a><p class="pBody">Now that you understand how certain instances of whitespace can be ignorable, it is time revise the definition of an &quot;empty&quot; element. That definition can now be expanded to include </p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">  &lt;foo&gt;   &lt;/foo&gt;<a name="wp65010"> </a></pre></div><a name="wp65011"> </a><p class="pBody">where there is whitespace between the tags and the DTD says that whitespace as ignorable.</p><a name="wp65166"> </a><h3 class="pHeading2">Echoing Entity References</h3><a name="wp95106"> </a><p class="pBody">When you wrote <code class="cCode">slideSample06.xml</code>, you defined entities for the product name. Now it's time to see how they're echoed when you process them with the SAX parser.</p><hr><a name="wp95131"> </a><p class="pNote">Note: The XML used here is contained in <code class="cCode"><a  href="../examples/xml/samples/slideSample06.xml" target="_blank">slideSample06.xml</a></code>, which references <code class="cCode"><a  href="../examples/xml/samples/slideshow1b.dtd" target="_blank">slideshow1b.dtd</a></code>, as described in <a  href="IntroXML4.html#wp68104">Defining Attributes and Entities in the DTD</a>. The output is shown in <code class="cCode"><a  href="../examples/jaxp/sax/samples/Echo09-06.txt" target="_blank">Echo09-06.txt</a></code>. (The browsable versions are <code class="cCode"><a  href="../examples/xml/samples/slideSample06-xml.html" target="_blank">slideSample06-xml.html</a></code>, <code class="cCode"><a  href="../examples/xml/samples/slideshow1b-dtd.html" target="_blank">slideshow1b-dtd.html</a></code> and <code class="cCode"><a  href="../examples/jaxp/sax/samples/Echo09-06.html" target="_blank">Echo09-06.html</a></code>.)</p><hr><a name="wp95140"> </a><p class="pBody">When you run the Echo program on <code class="cCode">slideSample06.xml</code>, here is the kind of thing you see:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">ELEMENT:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;CHARS:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wake up to <code class="cCodeBold">WonderWidgets</code>!END_ELM:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/title&gt;<a name="wp65168"> </a></pre></div><a name="wp65169"> </a><p class="pBody">Note that the product name has been substituted for the entity reference.</p><a name="wp65191"> </a><h3 class="pHeading2">Echoing the External Entity</h3><a name="wp95190"> </a><p class="pBody">In <code class="cCode">slideSample07.xml</code>, you defined an external entity to reference a copyright file.</p><hr><a name="wp95193"> </a><p class="pNote">Note: The XML used here is contained in <code class="cCode"><a  href="../examples/xml/samples/slideSample07.xml" target="_blank">slideSample07.xml</a></code> and in <code class="cCode"><a  href="../examples/jaxp/sax/samples/copyright.xml" target="_blank">copyright.xml</a></code>. The output is shown in <code class="cCode"><a  href="../examples/jaxp/sax/samples/Echo09-07.txt" target="_blank">Echo09-07.txt</a></code>. (The browsable versions are <code class="cCode"><a  href="../examples/xml/samples/slideSample07-xml.html" target="_blank">slideSample07-xml.html</a></code>, <code class="cCode"><a  href="../examples/jaxp/sax/samples/copyright-xml.html" target="_blank">copyright-xml.html</a></code> and<code class="cCode"><a  href="../examples/jaxp/sax/samples/Echo09-07.html" target="_blank"> Echo09-07.html</a></code>.)</p><hr><a name="wp65192"> </a><p class="pBody">When you run the Echo program on that version of the slide presentation, here is what you see:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">...END_ELM: &lt;/slide&gt;ELEMENT: &lt;slide&nbsp;&nbsp;ATTR: type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;all&quot;&gt;&nbsp;&nbsp;ELEMENT: &lt;item&gt;&nbsp;&nbsp;CHARS: This is the standard copyright message that our lawyersmake us put everywhere so we don&#39;t have to shell out amillion bucks every time someone spills hot coffee in theirlap...&nbsp;&nbsp;END_ELM: &lt;/item&gt;END_ELM: &lt;/slide&gt;...<a name="wp65193"> </a></pre></div><a name="wp65194"> </a><p class="pBody">Note that the newline which follows the comment in the file is echoed as a character, but that the comment itself is ignored. That is the reason that the copyright message appears to start on the next line after the <code class="cCode">CHARS:</code> label, instead of immediately after the label--the first character echoed is actually the newline that follows the comment.</p><a name="wp65196"> </a><h3 class="pHeading2">Summarizing Entities</h3><a name="wp65197"> </a><p class="pBody">An entity that is referenced in the document content, whether internal or external, is termed a general entity. An entity that contains DTD specifications that are referenced from within the DTD is termed a parameter entity. (More on that later.) </p><a name="wp65198"> </a><p class="pBody">An entity which contains XML (text and markup), and which is therefore parsed, is known as a <em class="cEmphasis">parsed entity</em>. An entity which contains binary data (like images) is known as an <em class="cEmphasis">unparsed entity</em>. (By its very nature, it must be external.) We'll be discussing references to unparsed entities in the next section of this tutorial.</p>    </blockquote>   <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="JAXPSAX6.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="JAXPSAX8.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -