Category Archives: Xml/Xslt

又是广告转换程序

星期四 天气:晴   今天上午集团组织体检了.   这些天做的,留个念想. 先上xml结构,这个是从数据获取的两个DataSet合并生成的.   <?xml version="1.0" encoding="gb2312"?><?xml-stylesheet type="text/xsl" href="newwindow.xslt"?><NewDataSet> <Table>  <iPositionID>1</iPositionID>  <cImageUrl>/img/1.jpg</cImageUrl>  <cDefaultText>最新广告</cDefaultText>  <iCycle>0.1</iCycle>  <iHeightSize>600</iHeightSize>  <iWidthSize>800</iWidthSize>  <!–0随机,1轮循–>  <iDisplayType>1</iDisplayType>  <gAttach>WV0IHZlcnNpb249IKbWF0Y2g9Iip8dGV4dCgpIjlZXQ+DQoNCiAg</gAttach> </Table>   <Table>  <iADItemID>1</iADItemID>  <cFileName>金镶玉2.jpg</cFileName>  <cFileType>image/jpg</cFileType>  <cLink>/map.aspx</cLink>  <cTitle>中llll国</cTitle> </Table>  <Table>  <iADItemID>3</iADItemID>  <cFileUrl>/img/pic-test-003.gif</cFileUrl>  <cFileType>image/jpg</cFileType>  <cLink>/Login.aspx</cLink>  <cTitle>中国</cTitle> </Table>  <Table>  <iADItemID>4</iADItemID>  <cFileUrl>/img/1.swf</cFileUrl>  <cFileType>application/x-shockwave-flash</cFileType>  <cTitle>Flash1</cTitle> </Table>  <Table>  <iADItemID>5</iADItemID>  <cFileUrl>/img/4.swf</cFileUrl>  <cFileType>application/x-shockwave-flash</cFileType>  <cLink></cLink>  <cTitle>Flash2</cTitle> </Table>  <Table>  <iADItemID>6</iADItemID>    <cLink>/map.aspx</cLink>  <cTitle>Flash2</cTitle> </Table> <!—-></NewDataSet> 这几个是转换程序,个个都有一身好武艺. Comm.xslt<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:msxsl="urn:schemas-microsoft-com:xslt"  xmlns:dyens="http://localhost/">  <msxsl:script implements-prefix="dyens" language="javascript"> <![CDATA[  function GetRandomInt(iNum)  {   return Math.floor(Math.random() * (iNum + 1) );  } ]]> </msxsl:script> <!– <msxsl:script implements-prefix="dyens" language="CSharp"> <![CDATA[  public int GetRandomInt_CSharp(iNum)  {   return new Random().Next(0,iNum);  } ]]> </msxsl:script> –></xsl:stylesheet>SimpleText.xslt<?xml version="1.0" encoding="gb2312" ?><xsl:stylesheet … 繼續閱讀

发表在 Xml/Xslt | 发表评论

节点集与结果树片断

  承清一下它们的分别:   节点集是xslt内部的一种类型,可以在样式表中直接以$var变量的方式引用.   而后者需要用例如:msxsl:node-set 函数使您能够将结果树片段转换成节点集,以这样的方式引用msxsl:node-set($var)/book. 它是非xpath数据类型(string,number,boolean,node-set).

发表在 Xml/Xslt | 发表评论

增强的广告飘浮与定位广告.

n久以前的 样式表 <?xml version="1.0" encoding="GB2312"?><!–作者:杨林 at 2005-08-?? –><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/>  <xsl:template match="/Config">    <xsl:if test="AD/FloatType[.=1][../Enabled='true']">   <xsl:call-template name="getCodeOfFloat"/>  </xsl:if>    <xsl:if test="AD/FloatType[.=2][../Enabled='true']">   <xsl:call-template name="getCodeOfPosition"/>  </xsl:if>    <script language="javascript">   <xsl:for-each select="AD">    <xsl:if test="Enabled and not(Enabled=’false’)">      <xsl:variable name="linkAddr">       <xsl:choose>        <xsl:when test="LimitTime/TimeSlice and LimitTime/TimeSlice/BeginTime and LimitTime/TimeSlice/BeginTime!=” and LimitTime/TimeSlice/EndTime!=”">/Frame/FloatAD/FloatControl.aspx?id=<xsl:value-of select="./Id" /></xsl:when>        <xsl:otherwise>         <xsl:value-of select="LinkAddr"/>        </xsl:otherwise>       </xsl:choose>      </xsl:variable>      <xsl:call-template name="runCode">       <xsl:with-param name="photoURL" select="PhotoURL"/>       <xsl:with-param name="fileType" select="FileType"/>       <xsl:with-param name="photoHeight" select="PhotoHeight"/>       <xsl:with-param name="photoWidth" … 繼續閱讀

发表在 Xml/Xslt | 发表评论

增强的轮播广告

06年的货了 样式表 <?xml version="1.0" encoding="GB2312" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:output method="html"/>  <xsl:template match="/">  <img src="{Advertisements/Ad[position()=1]/ImageUrl}" id="imgAd" style="cursor:hand;FILTER: revealTrans(Duration=3.0,Transition=1)"/>    <xsl:value-of select="document(”)/*/node()[@name='ScriptData']/node()" disable-output-escaping="yes"/>  <script language="JavaScript">   <xsl:apply-templates/>  </script> </xsl:template>  <xsl:template match="Advertisements">            <xsl:variable name="ads" select="Ad[Disabled = 'false']"/>    <xsl:variable name="ads_count" select="count($ads)"/>        var oAD = new Array(<xsl:value-of select="$ads_count"/>);    var iADCount = <xsl:value-of select="$ads_count"/>    <xsl:for-each select="$ads">     <xsl:if test="Type=’image’">           oAD[<xsl:value-of select="position()-1"/>] = new Object();      oAD[<xsl:value-of select="position()-1"/>].Type … 繼續閱讀

发表在 Xml/Xslt | 发表评论

自由线程FreeThreadDOMDocument

星期二 天气:晴   昨天燕子 自己去五爱了 给我买了一堆袜子 给妈买了一双鞋 给自己买了一件 红色的内衣服 挺好看的 在市场买了一碗麻辣烫 买了二斤香樵    一般是用在多线程中的,不过现在好像用不到了这种对象了 除非你还在用asp来写后台程序、或者用 vb、vc之类com组件编程。 function Test(){    var xmlDom = new ActiveXObject("Msxml2.DOMDocument");    xmlDom.async = false;    xmlDom.loadXML(…);     if(xmlDom.parseError.errorCode != 0){     var myErr = xmlDom.parseError;     alert("XML 加载错误: " + myErr.reason);    }else{     var xslt = new ActiveXObject("Msxml2.XSLTemplate");     var xsltDom = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");     xsltDom.async = false;     xsltDom.load("??.xslt");          if(xsltDom.parseError.errorCode != 0) {      var myErr = xsltDom.parseError;      alert("XSLT … 繼續閱讀

发表在 Xml/Xslt | 1条评论

定点广告与漂浮广告

配置文件 XML 内容   <?xml version="1.0" encoding="GB2312"?> <Config> <AD>  <!–是否可用–>  <Enabled>true</Enabled>  <!–浮动类型1为随机浮动,2为定点浮动–>  <FloatType>1</FloatType>  <!–文件类型包括swf,或(image)各种web支持的图片格式,图片格式不用设置高度,宽度–>  <FileType>swf</FileType>  <PhotoURL>http://image2.sina.com.cn/dy/ad/cmad120x250a.swf</PhotoURL>  <LinkAddr>http://user.7host.com/ioriwellings/</LinkAddr>  <PopupHeight></PopupHeight>  <PopupWidth></PopupWidth>  <PhotoTop>100</PhotoTop>  <PhotoLeft>20</PhotoLeft>  <PhotoHeight>250</PhotoHeight>  <PhotoWidth>120</PhotoWidth> </AD>  <AD>  <!–是否可用–>  <Enabled>true</Enabled>  <!–浮动类型1为随机浮动,2为定点浮动–>  <FloatType>2</FloatType>  <!–文件类型包括swf,或(image)各种web支持的图片格式,图片格式不用设置高度,宽度–>  <FileType>image</FileType>  <PhotoURL>http://www.sanhaostreet.com/imagesindex/indexnew_shop.jpg</PhotoURL>  <LinkAddr>http://user.7host.com/ioriwellings/</LinkAddr>  <PopupHeight>250</PopupHeight>  <PopupWidth>120</PopupWidth>  <PhotoTop>100</PhotoTop>  <PhotoLeft>20</PhotoLeft>  <PhotoHeight>90</PhotoHeight>  <PhotoWidth>90</PhotoWidth> </AD>  <AD>  <!–是否可用–>  <Enabled>true</Enabled>  <!–浮动类型1为随机浮动,2为定点浮动–>  <FloatType>1</FloatType>  … 繼續閱讀

发表在 Xml/Xslt | 1条评论

转我的留言板一页

JavaX 作者 主题: 设计模式:递归与分组 八神[过客] 发表于: 8/25/2005 1:34:55 AM 递归: 编写一个递归模板,将整个列表作为参数传给它.如果列表不为空,则处理它的第一项,然后递归调用自身来处理列表除第一项以外的其余部分.   例子: 计算总销售额   数据文件     <booklist>        <book>           <title>Angela’s Ashes</title>           <author>Frank McCourt</author>           <publisher>HarperCollins</publisher>           <isbn>0 00 649840 X</isbn>           <price>6.99</price>           <sales>235</sales>        </book>        <book>           <title>Sword of Honour</title>           <author>Evelyn Waugh</author>           <publisher>Penguin Books</publisher>           <isbn>0 14 018967 X</isbn>           <price>12.99</price>           <sales>12</sales>        </book>     </booklist>   样式表   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">     <xsl:template name="total-sales-value">         <xsl:param name="list"/>         <xsl:choose>             <xsl:when test="$list">                 <xsl:variable name="first" select="$list[1]"/>                 <xsl:variable name="total-of-rest">                     <xsl:call-templates name="total-sales-value"> … 繼續閱讀

发表在 Xml/Xslt | 发表评论

广告轮播

将以前的一段脚本 改成组件了   XSLT 文件 AdRotator.xslt <?xml version="1.0" encoding="GB2312" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:output method="html"/>  <xsl:template match="/">  <img src="{Advertisements/Ad[position()=1]/ImageUrl}" id="imgAd" style="cursor:hand;FILTER: revealTrans(Duration=3.0,Transition=1)"/>  <xsl:value-of select="document(”)/*/node()[@name='ScriptData']/node()" disable-output-escaping="yes"/>  <script language="JavaScript">   <xsl:apply-templates/>  </script> </xsl:template>  <xsl:template match="Advertisements">    var myImages = new Array(<xsl:value-of select="count(Ad)"/>);    <xsl:for-each select="Ad">     myImages[<xsl:value-of select="position()-1"/>] = new Image();     myImages[<xsl:value-of select="position()-1"/>].src = "<xsl:value-of select="ImageUrl"/>"     myImages[<xsl:value-of select="position()-1"/>].onclick = function(){      window.open(‘<xsl:value-of select="NavigateUrl"/>’,”,’left=0,top=0,height=<xsl:value-of … 繼續閱讀

发表在 Xml/Xslt | 1条评论