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

📄 introxml5.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="wp65045"> </a><p class="pBody">External entities produce modular XML that is smaller, easier to update and maintain. They can also make the resulting document somewhat more difficult to visualize, much as a good OO design can be easy to change, once you understand it, but harder to wrap your head around at first.</p><a name="wp65046"> </a><p class="pBody">You can also go overboard with entities. At an extreme, you could make an entity reference for the word &quot;the&quot;--it wouldn't buy you much, but you could do it.</p><hr><a name="wp65047"> </a><p class="pNote">Note: The larger an entity is, the less likely it is that changing it will have unintended effects. When you define an external entity that covers a whole section on installation instructions, for example, making changes to the section is unlikely to make any of the documents that depend on it come out wrong. Small inline substitutions can be more problematic, though. For example, if <code class="cCode">productName</code> is defined as an entity, the name change can be to a different part of speech, and that can produce! Suppose the product name is something like &quot;HtmlEdit&quot;. That's a verb. So you write a sentence that becomes, &quot;You can HtmlEdit your file...&quot; after the entity-substitution occurs. That sentence reads fine, because the verb fits well in that context. But if the name is eventually changed to &quot;HtmlEditor&quot;, the sentence becomes &quot;You can HtmlEditor your file...&quot;, which clearly doesn't work. Still, even if such simple substitutions can sometimes get you in trouble, they can potentially save a lot of time. (One alternative would be to set up entities named <code class="cCode">productNoun</code>, <code class="cCode">productVerb</code>, <code class="cCode">productAdj</code>, and <code class="cCode">productAdverb</code>!)</p><hr><a name="wp65049"> </a><h3 class="pHeading2">Normalizing DTDs</h3><a name="wp65050"> </a><p class="pBody">Just as you can normalize your XML document, you can also normalize your DTD declarations by factoring out common pieces and referencing them with a parameter entity. Factoring out the DTDs (also known as modularizing or normalizing) gives the same advantages and disadvantages as normalized XML--easier to change, somewhat more difficult to follow.</p><a name="wp65420"> </a><p class="pBody">You can also set up conditionalized DTDs. If the number and size of the conditional sections is small relative to the size of the DTD as a whole, that can let you &quot;single source&quot; a DTD that you can use for multiple purposes. If the number of conditional sections gets large, though, the result can be a complex document that is difficult to edit.</p><a name="wp71637"> </a><h3 class="pHeading2">Summary</h3><a name="wp71638"> </a><p class="pBody">Congratulations! You have now created a number of XML files that you can use for testing purposes. Here's a table that describes the files you have constructed. </p><div align="left"><table border="1" summary="Listing of Sample XML Files" id="wp71642">  <caption><a name="wp71642"> </a><div class="pTableTitle">Table 2-5   Listing of Sample XML Files</div></caption>  <tr align="center">    <th><a name="wp71646"> </a><div class="pCellHeading">    File</div></th>    <th><a name="wp71648"> </a><div class="pCellHeading">Contents</div></th></tr>  <tr align="left">    <td><a name="wp71650"> </a><div class="pCellHeading"> slideSample01.xml</div></td>    <td><a name="wp71652"> </a><div class="pCellBody">A basic file containing a few elements and attributes, as well as comments.</div></td></tr>  <tr align="left">    <td><a name="wp71654"> </a><div class="pCellHeading"> slideSample02.xml</div></td>    <td><a name="wp71656"> </a><div class="pCellBody">Includes a processing instruction.</div></td></tr>  <tr align="left">    <td><a name="wp71658"> </a><div class="pCellHeading"> SlideSampleBad1.xml</div></td>    <td><a name="wp71660"> </a><div class="pCellBody">A file that is <span style="font-style: italic">not</span> well-formed.</div></td></tr>  <tr align="left">    <td><a name="wp71662"> </a><div class="pCellHeading"> slideSample03.xml</div></td>    <td><a name="wp71664"> </a><div class="pCellBody">Includes a simple entity reference (&amp;lt;).</div></td></tr>  <tr align="left">    <td><a name="wp71666"> </a><div class="pCellHeading"> slideSample04.xml</div></td>    <td><a name="wp71668"> </a><div class="pCellBody">Contains a CDATA section.</div></td></tr>  <tr align="left">    <td><a name="wp71670"> </a><div class="pCellHeading"> slideSample05.xml</div></td>    <td><a name="wp71672"> </a><div class="pCellBody">References either a simple external DTD for elements (<code class="cCode">slideshow1a.dtd</code>), for use with a nonvalidating parser, or else a DTD that defines attributes (<code class="cCode">slideshow1b.dtd</code>) for use with a validating parser.</div></td></tr>  <tr align="left">    <td><a name="wp71674"> </a><div class="pCellHeading"> slideSample06.xml</div></td>    <td><a name="wp71676"> </a><div class="pCellBody">Defines two entities locally (product and products), and references <code class="cCode">slideshow1b.dtd</code>.</div></td></tr>  <tr align="left">    <td><a name="wp71678"> </a><div class="pCellHeading"> slideSample07.xml</div></td>    <td><a name="wp71680"> </a><div class="pCellBody">References an external entity defined locally (<code class="cCode">copyright.xml</code>), and references <code class="cCode">slideshow1b.dtd</code>.</div></td></tr>  <tr align="left">    <td><a name="wp71682"> </a><div class="pCellHeading"> slideSample08.xml</div></td>    <td><a name="wp71684"> </a><div class="pCellBody">References <code class="cCode">xhtml.dtd</code> using a parameter entity in <code class="cCode">slideshow2.dtd</code>, producing a naming conflict, since <code class="cCode">title</code> is declared in both.</div></td></tr>  <tr align="left">    <td><a name="wp71686"> </a><div class="pCellHeading"> slideSample09.xml</div></td>    <td><a name="wp71688"> </a><div class="pCellBody">Changes the <code class="cCode">title</code> element to <code class="cCode">slide-title</code>, so it can reference <code class="cCode">xhtml.dtd</code> using a parameter entity in <code class="cCode">slideshow3.dtd</code> without conflict. </div></td></tr></table></div><p class="pBody"></p><a name="wp71635"> </a><p class="pBody"></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="IntroXML4.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="WebApp.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 + -