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

📄 transforming the contents of xml data islands using xsl.htm

📁 这是一本关于XML的学习的书
💻 HTM
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb_2312-80">
<TITLE>使用Xsl转换Xml数据岛的内容</TITLE>
<style type="text/css">
<!--
.normal10 {  font-size: 11pt}
.normal9 {  font-size: 9pt}
a{ text-decoration: none }
a:hover{ color:Red;text-decoration:underline }
a {
font-size:11pt;   
COLOR: cornflowerblue;
FONT-FAMILY: "新细明体", "宋体";
FONT-WEIGHT: bold
 }
.normal105 {  font-size: 11pt}
.p {  font-size: 11pt}

-->
</style>
<link rel="stylesheet" href="../../Global.css" tppabs="http://www.xml.org.cn:8188/Global.css"></HEAD>
<BODY>
<p ALIGN="CENTER" class="normal105">[<a href="../../default.asp.htm" tppabs="http://www.xml.org.cn:8188/default.asp" target="_parent">返回首页</a>][<font face="宋体" lang="ZH-CN"><a href="../application.htm" tppabs="http://www.xml.org.cn:8188/application/application.htm" target="_parent">返回应用</a></font>]</p>
<table width="85%" border="0" align="center">
  <tr> 
    <td width="22%" height="56">&nbsp;</td>
    <td width="53%" height="56"> 
      <h2 align="center">使用Xsl转换Xml数据岛的内容</h2>
      </td>
    <td width="25%" height="56"><a name="top"></a></td>
  </tr>
  <tr> 
    <td colspan="3" height="418"> 
      <p> <span class="normal10"><br>
        <span class="normal105">下一篇: <font face="Arial"><a href="Using XSL in an Active Server Page.htm" tppabs="http://www.xml.org.cn:8188/application/XSL%20uguid/Using%20XSL%20in%20an%20Active%20Server%20Page.htm" class="normal105">在Active 
        Server Page中使用XSL</a></font> <br>
        返 回 : <a href="Using the XSL Processor.htm" tppabs="http://www.xml.org.cn:8188/application/XSL%20uguid/Using%20the%20XSL%20Processor.htm" class="normal105">使用XSL处理程序</a> 
        </span></span></p>
      <p><span class="normal105"><font 
      face=宋体>数据岛提供了一种方便的方法从HTML网页中访问Xml数据.由于Xsl自己也是一种Xml语法,数据岛也提供了一种方便的方法来加载样式表.下面的样例使用了两个数据岛来加载Xml元数据和Xsl样式表.在这两个数据岛上使用的<b>transformNode</b>方法来产生以后能插入网页中的HTMl代码.</font></span></p>
      <pre class=clsCode><span class="normal105"><font face=宋体>&lt;HTML&gt;
  &lt;HEAD&gt;
    &lt;TITLE&gt;Simple demo of Microsoft XSL Processor&lt;/TITLE&gt;
  &lt;/HEAD&gt;

  &lt;XML id="source" src="simple.xml"&gt;&lt;/XML&gt;
  &lt;XML id="style" src="simple.xsl"&gt;&lt;/XML&gt;
  
  &lt;SCRIPT FOR="window" EVENT="onload"&gt;
    xslTarget.innerHTML = source.transformNode(style.XMLDocument);
  &lt;/SCRIPT&gt;

  &lt;BODY&gt;
    &lt;P STYLE="font-size:10pt; font-family:Verdana; color:gray"&gt;
      &lt;B&gt;This demo shows the use of data islands for loading XML source and 
      XSL style sheets and inserting the transformed result into the Web page.&lt;/B&gt;
    &lt;/P&gt;
    &lt;DIV id="xslTarget"&gt;&lt;/DIV&gt;
  &lt;/BODY&gt;
&lt;/HTML&gt;</font></span></pre>
      <p><span class="normal105"><font 
      face=宋体>当上面的网页完全下载以后(包括数据岛),<b>onload</b>事件被激发,<b>transformNode</b>方法在基于Xml元数据上被执行.<b>transformNode</b>带有一个单独的参数,它是一个描述Xsl样式表的DOM节点.这个调用的返回值是一个XML文本.由于在样例中使用的simple.xsl样式表产生了一个结构良好的HTML文档,因此你可以使用innerHTML属性把这个样式表的结果插入id为xslTarget的<b>Div 
        </b>元素来显示xml文档.</font></span></p>
      <p><span class="normal105"><font face=宋体>注意:<b>XmlDocument</b>属性是在"style"数据岛上使用的.<font 
      color=#0>没有这个属性,数据岛的id(例如,"style")将会被认为是一个确定的HTML元素,或者是我们所讨论的</font><font 
      color=#0 face=宋体>&lt;XML&gt;元素</font>.XMLDocument 能被用于明确地从&lt;XML&gt;元素中得到Xml 
        DOM文档节点.书写style.XMLDocument将其解释为你正在操纵数据岛的内容而不是&lt;XML&gt;元素来描述数据岛.</font></span></p>
      <p><span class="normal105"><font 
      face=宋体>那么为什么你可以不写为source.XMLDocument.transformNode(style.XMLDocument)?这里有一些有用的但是不可思议的行为.如果一个<b>Xml 
        DOM</b>方法被应用于数据岛元素,script引擎接口将会推断你希望这个方法被替换而应用于<b>XML DOM</b>文档节点,应此如果的DOM属性和方法正在被应用的时候就能忽略<b>XMLDocument</b>属性.例如<font 
      color=#0>在"source"数据岛这种情况下,如果你正在调用一个DOM方法(<b>transformNode</b>),就不需要<b>XMLDocument</b>了.</font></font></span></p>
      <p><span class="normal105"><font 
      face=宋体>你也可以写成source.XMLDocument.transformNode(style.documentElement)并且将样式表应用于文档元素来代替文档根,但是样式表也必须相应变化.例如,文档元素必须通过一个不同于根模扳 
        xsl:template match="/"的规则来操纵,除非样式表从文档的根开始执行否则它不可能被调用.<font 
      color=#0>处理样式表时最好不要涉及文档根,以便他们也能工作于直接浏览Xml文档的任务.</font>一些文档根和文档元素的区别的注释你可以在"DOM是如何为Xsl模式化查询定义上下文的"中找到.</font></span></p>
      <p><span class="normal105"><font face=宋体><b>尝试!</b> 上面的例子是 <a 
      href="../../../msdn.microsoft.com/xml/samples/breakfast-menu/simple-islands.htm" tppabs="http://msdn.microsoft.com/xml/samples/breakfast-menu/simple-islands.htm">Breakfast 
        Menu Demo (Data Islands)</a>的一部分.</font></span></p>
      <p><span class="normal105"><font face=宋体><a 
      href="../../../msdn.microsoft.com/xml/samples/breakfast-menu/simple-islands.zip" tppabs="http://msdn.microsoft.com/xml/samples/breakfast-menu/simple-islands.zip"><img 
      alt=Download border=0 height=20 src="" width=16> Download this sample</a>. 
        </font></span></p>
      <p><span class="normal105"><font face=宋体>对于更多的信息,参见下面相关的主题:</font></span></p>
      <ul>
        <li><span class="normal105"><font face=宋体><a 
        href="../../../msdn.microsoft.com/xml/xmlguide/dataIslandhowto.asp" tppabs="http://msdn.microsoft.com/xml/xmlguide/dataIslandhowto.asp">XML 
          Data Islands</a> </font> </span>
        <li><span class="normal105"><font face=宋体><a 
        href="../../../msdn.microsoft.com/xml/xslguide/transform-errors.asp" tppabs="http://msdn.microsoft.com/xml/xslguide/transform-errors.asp">Detecting 
          and Handling XSL Errors</a> </font> </span>
        <li><span class="normal105"><font face=宋体><a 
        href="../../../msdn.microsoft.com/xml/xslguide/transform-tree.asp" tppabs="http://msdn.microsoft.com/xml/xslguide/transform-tree.asp">Getting 
          the Results of an XSL Transformation as a New DOM Document</a></font></span><font face=宋体> 
          </font></li>
      </ul>
    </td>
  </tr>
  <tr> 
    <td colspan="3"><font face="宋体" lang="ZH-CN" size=3> </font> <rev></rev><font face="宋体" lang="ZH-CN" size=3></font> 
      <hr size="1">
      <p align="center"><font face="宋体" lang="ZH-CN">[<a href="#top">返回标题</a>][<a href="../application.htm" tppabs="http://www.xml.org.cn:8188/application/application.htm" target="_parent">返回应用</a>][<a href="../../default.asp.htm" tppabs="http://www.xml.org.cn:8188/default.asp" target="_parent">返回首页</a>][<a href="mailto:xmlteam@egroups.com">欢迎投稿</a>]</font></p>
      <p align="center">最后更新:1999年9月15日<br>
        <font color="#FF0033" size="-1">本站点所刊文章版权,均归本站点所有。署名作者拥有其著作权。<br>
        未经</font><font color="#FF0033"><a href="mailto:xmlteam@egroups.com"><font color="#6666FF" size="-1">允许</font></a></font><font color="#FF0033" size="-1">,不得随意转载,违者必究!!</font> 
      </p>
    </td>
  </tr>
</table>
<h2 ALIGN="CENTER">&nbsp;</h2>
<FONT FACE="宋体" LANG="ZH-CN" SIZE=3> 
<P ALIGN="JUSTIFY">&nbsp;</P>
</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3></FONT> 
</BODY>
</HTML>

⌨️ 快捷键说明

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