星期四 天气:晴
今天上午集团组织体检了.
这些天做的,留个念想.
先上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 version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:dyens="http://localhost/"> <xsl:import href="Comm.xslt"/> <xsl:output method="html" /> <!--广告位--> <xsl:template match="/NewDataSet/Table[iPositionID]"> <!--<textarea cols="500" rows="35">--> <!--DIV开始--> <xsl:element name="div"> <xsl:attribute name="style"> <xsl:value-of select="concat('position:relative;overflow:hidden;top:0px;left:0px;width:', iWidthSize, 'px;height:', iHeightSize, 'px')" /> </xsl:attribute> <a id="labItem_{iPositionID}"> </a> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <SCRIPT LANGUAGE="JavaScript"> <xsl:choose> <xsl:when test="iDisplayType=1"> <xsl:call-template name="GetRollScript"> <xsl:with-param name="_iPositionID" select="iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> <xsl:with-param name="_iCycle" select="iCycle" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="GetRandomScript"> <xsl:with-param name="_iPositionID" select="iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> <xsl:if test="$_ADItems=''"> <xsl:call-template name="GetDefaultScript"> <xsl:with-param name="_iPositionID" select="iPositionID" /> <xsl:with-param name="_defaultText" select="cDefaultText" /> </xsl:call-template> </xsl:if> </SCRIPT> </xsl:element> <!--DIV块结束--> <!--</textarea>--> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID)]"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <Text><xsl:value-of select="cTitle" /></Text> <Href><xsl:value-of select="cLink" /></Href> </Item> </xsl:for-each> </xsl:template> <!--默认脚本--> <xsl:template name="GetDefaultScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_defaultText" /> var o = document.getElementById("labItem_<xsl:value-of select="$_iPositionID" />"); o.innerText = "<xsl:value-of select="$_defaultText" />"; </xsl:template> <!--获取随机脚本--> <xsl:template name="GetRandomScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:if test="count($_ADItems/Item) > 0"> <!--随机数0到广告数减1.--> <xsl:variable name="_i" select="dyens:GetRandomInt(count($_ADItems/Item)-1)"></xsl:variable> <xsl:variable name="_item" select="$_ADItems/Item[position()=$_i+1]" /> var o = document.getElementById("labItem_<xsl:value-of select="$_iPositionID" />"); o.innerText = "<xsl:value-of select="$_item/Text" />"; <xsl:if test="$_item/Href and $_item/Href != ''"> o.href = "/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="$_item/Href" />&id=<xsl:value-of select="$_item/ADItemID" />"; o.target = "_blank"; </xsl:if> </xsl:if> </xsl:template> <!--获取轮循脚本--> <xsl:template name="GetRollScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:param name="_iCycle" /> function ADItem(text, url) { this.Text = text; this.Url = url; } count_<xsl:value-of select="$_iPositionID" /> = 0; var _aditemCollection_<xsl:value-of select="$_iPositionID" /> = new Array(); var _aditem; <xsl:for-each select="$_ADItems/Item"> <xsl:choose> <xsl:when test="Href=''"> _aditem = new ADItem("<xsl:value-of select="Text" />"); </xsl:when> <xsl:otherwise> _aditem = new ADItem("<xsl:value-of select="Text" />", "/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="Href" />&id=<xsl:value-of select="ADItemID" />") </xsl:otherwise> </xsl:choose> _aditemCollection_<xsl:value-of select="$_iPositionID" />.push(_aditem); </xsl:for-each> Roll_<xsl:value-of select="$_iPositionID" />(); function Roll_<xsl:value-of select="$_iPositionID" />() { if(count_<xsl:value-of select="$_iPositionID" /> >= _aditemCollection_<xsl:value-of select="$_iPositionID" />.length) { count_<xsl:value-of select="$_iPositionID" /> = 0; } var o = document.getElementById("labItem_<xsl:value-of select="$_iPositionID" />"); o.innerText = _aditemCollection_<xsl:value-of select="$_iPositionID" />[count_<xsl:value-of select="$_iPositionID" />].Text; var items = _aditemCollection_<xsl:value-of select="$_iPositionID" />; var i = count_<xsl:value-of select="$_iPositionID" />; if(items[i].Url != null && items[i].Url != "") { o.href = items[i].Url; o.target = "_blank"; } else { o.removeAttribute("href"); o.removeAttribute("target"); } count_<xsl:value-of select="$_iPositionID" />++; setTimeout(Roll_<xsl:value-of select="$_iPositionID" />, <xsl:value-of select="$_iCycle" />*60000); } </xsl:template> <xsl:template match="text()"></xsl:template> </xsl:stylesheet> ------------------------------SimpleImage.xslt------------------------------------- <?xml version="1.0" encoding="GB2312" ?> <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/" exclude-result-prefixes="dyens msxsl xsl"> <xsl:import href="Comm.xslt"/> <xsl:output method="html" /> <xsl:template match="/"> <xsl:call-template name="ADPosition"></xsl:call-template> </xsl:template> <!--广告位--> <xsl:template name="ADPosition"> <xsl:variable name="_adPosition" select="/NewDataSet/Table[iPositionID]" /> <!--DIV开始--> <xsl:element name="div"> <!--链接与图片--> <xsl:attribute name="style"> <xsl:value-of select="concat('position:relative;overflow:hidden;width:', $_adPosition/iWidthSize, 'px;height:', $_adPosition/iHeightSize, 'px')" /> </xsl:attribute> <a id="labItem_{$_adPosition/iPositionID}"><img id="imgItem_{$_adPosition/iPositionID}" border="0" /></a> <script language="javascript"> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <xsl:choose> <xsl:when test="count(msxsl:node-set($_ADItems)/Item) > 0"> <xsl:choose> <xsl:when test="$_adPosition/iDisplayType=1"> <xsl:call-template name="GetRollScript"> <xsl:with-param name="_iPositionID" select="$_adPosition/iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> <xsl:with-param name="_iCycle" select="$_adPosition/iCycle" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="GetRandomScript"> <xsl:with-param name="_iPositionID" select="$_adPosition/iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:call-template name="GetDefaultScript"> <xsl:with-param name="_iPositionID" select="$_adPosition/iPositionID" /> <xsl:with-param name="_defaultImage" select="$_adPosition/cImageUrl" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </script> </xsl:element> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID) and cFileType='image/jpg']"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <Image><xsl:choose> <xsl:when test="cFileUrl"> <xsl:value-of select="cFileUrl" /> </xsl:when> <xsl:otherwise>/ADManager/GetFile.aspx?type=2&id=<xsl:value-of select="iADItemID" /> </xsl:otherwise> </xsl:choose> </Image> <Text> <xsl:value-of select="cTitle" /> </Text> <Href> <xsl:if test="cLink and cLink != ''">/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="cLink" />&id=<xsl:value-of select="iADItemID" /></xsl:if> </Href> </Item> </xsl:for-each> </xsl:template> <!--默认脚本--> <xsl:template name="GetDefaultScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_defaultImage" /> var oImg = document.getElementById("imgItem_<xsl:value-of select="$_iPositionID" />"); oImg.src = "<xsl:value-of select="$_defaultImage" />"; </xsl:template> <!--获取轮循脚本--> <xsl:template name="GetRollScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:param name="_iCycle" /> <![CDATA[ function ADImage(src, url, title) { this.Src = src; this.Url = url; this.Title = title; } function SimpleImage(items, lab, img, iCycle) { var i=0; function Roll() { if(i >= items.length) { i=0; } var oHref = lab;//document.getElementById("labItem"); var oImg = img;//document.getElementById("imgItem"); oImg.src = items[i].Src; if(items[i].Url != null && items[i].Url != "") { oHref.href = items[i].Url; oHref.target = "_blank"; } else { oHref.removeAttribute("href"); oHref.removeAttribute("target"); } if(items[i].Title != null) { oImg.title = items[i].Title; } else { oImg.removeAttribute("title"); } i++; window.setTimeout(Roll, iCycle*60000); } this.Roll = Roll; } ]]> var _aditemCollection_<xsl:value-of select="$_iPositionID" /> = new Array(); var _aditem; <xsl:for-each select="$_ADItems/Item"> _aditem = new ADImage("<xsl:value-of select="Image" />", "<xsl:value-of select="Href" />", "<xsl:value-of select="Text" />"); _aditemCollection_<xsl:value-of select="$_iPositionID" />.push(_aditem); </xsl:for-each> new SimpleImage(_aditemCollection_<xsl:value-of select="$_iPositionID" />, document.getElementById("labItem_<xsl:value-of select="$_iPositionID" />"), document.getElementById("imgItem_<xsl:value-of select="$_iPositionID" />"), <xsl:value-of select="$_iCycle" />).Roll(); </xsl:template> <!--获取随机脚本--> <xsl:template name="GetRandomScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:variable name="_i" select="dyens:GetRandomInt(count($_ADItems/Item)-1)"></xsl:variable> <xsl:variable name="_item" select="$_ADItems/Item[position()=$_i+1]" /> var oHref = document.getElementById("labItem_<xsl:value-of select="$_iPositionID" />"); var oImg = document.getElementById("imgItem_<xsl:value-of select="$_iPositionID" />"); oImg.src = "<xsl:value-of select="$_item/Image" />"; <xsl:if test="$_item/Href and $_item/Href != ''"> oHref.href = "<xsl:value-of select="$_item/Href" />"; oHref.target = "_blank"; </xsl:if> <xsl:if test="$_item/Text and $_item/Text != ''"> oImg.title = "<xsl:value-of select="$_item/Text" />"; </xsl:if> </xsl:template> </xsl:stylesheet> ------------------------------------SimpleFlash.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/" exclude-result-prefixes="dyens msxsl xsl"> <xsl:import href="Comm.xslt"/> <xsl:output method="html" /> <xsl:template match="/"> <xsl:call-template name="ADPosition"></xsl:call-template> </xsl:template> <!--广告位--> <xsl:template name="ADPosition"> <xsl:variable name="_adPosition" select="/NewDataSet/Table[iPositionID]" /> <!--DIV开始--> <xsl:element name="div"> <xsl:attribute name="style"> <xsl:value-of select="concat('position:relative;overflow:hidden;width:', $_adPosition/iWidthSize, 'px;height:', $_adPosition/iHeightSize, 'px')" /> </xsl:attribute> <OBJECT id="swfAd_{$_adPosition/iPositionID}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" VIEWASTEXT=""> <PARAM NAME="Movie" VALUE="" /> <PARAM NAME="Src" VALUE="" /> <PARAM NAME="Quality" VALUE="High" /> </OBJECT> <script language="javascript"> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <xsl:choose> <xsl:when test="count(msxsl:node-set($_ADItems)/Item) > 0"> <xsl:choose> <xsl:when test="$_adPosition/iDisplayType=1"> <xsl:call-template name="GetRollScript"> <xsl:with-param name="_iPositionID" select="$_adPosition/iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> <xsl:with-param name="_iCycle" select="$_adPosition/iCycle" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="GetRandomScript"> <xsl:with-param name="_iPositionID" select="$_adPosition/iPositionID"></xsl:with-param> <xsl:with-param name="_ADItems" select="msxsl:node-set($_ADItems)"></xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:when> </xsl:choose> </script> </xsl:element> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID) and cFileType='application/x-shockwave-flash']"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <Flash><xsl:choose> <xsl:when test="cFileUrl"> <xsl:value-of select="cFileUrl" /> </xsl:when> <xsl:otherwise>/ADManager/GetFile.aspx?type=3&id=<xsl:value-of select="iADItemID" /> </xsl:otherwise> </xsl:choose> </Flash> </Item> </xsl:for-each> </xsl:template> <!--获取轮循脚本--> <xsl:template name="GetRollScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:param name="_iCycle" /> <![CDATA[ function ADFlash(src) { this.Src = src; } function SimpleFlash(items, oSwf, iCycle) { var i=0; function Roll() { if(i >= items.length) { i=0; } oSwf.Src = items[i].Src; oSwf.Movie = oSwf.Src i++; window.setTimeout(Roll, iCycle*60000); } this.Roll = Roll; } ]]> var _aditemCollection_<xsl:value-of select="$_iPositionID" /> = new Array(); var _aditem; <xsl:for-each select="$_ADItems/Item"> _aditem = new ADFlash("<xsl:value-of select="Flash" />"); _aditemCollection_<xsl:value-of select="$_iPositionID" />.push(_aditem); </xsl:for-each> new SimpleFlash(_aditemCollection_<xsl:value-of select="$_iPositionID" />, document.getElementById("swfAd_<xsl:value-of select="$_iPositionID" />"), <xsl:value-of select="$_iCycle" />).Roll(); </xsl:template> <!--获取随机脚本--> <xsl:template name="GetRandomScript"> <xsl:param name="_iPositionID" /> <xsl:param name="_ADItems" /> <xsl:variable name="_i" select="dyens:GetRandomInt(count($_ADItems/Item)-1)"></xsl:variable> <xsl:variable name="_item" select="$_ADItems/Item[position()=$_i+1]" /> var oFlash = document.getElementById("swfAd_<xsl:value-of select="$_iPositionID" />"); oFlash.Src = "<xsl:value-of select="$_item/Flash" />"; oFlash.Movie = oFlash.Src; </xsl:template> </xsl:stylesheet> --------------------------------------NewWindow.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/" exclude-result-prefixes="dyens msxsl xsl"> <xsl:import href="Comm.xslt"/> <xsl:output method="xml" /> <xsl:template match="/"> <xsl:call-template name="ADPosition"></xsl:call-template> </xsl:template> <!--广告位--> <xsl:template name="ADPosition"> <xsl:variable name="_adPosition" select="/NewDataSet/Table[iPositionID]" /> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <xsl:if test="count(msxsl:node-set($_ADItems)/Item) > 0"> <script language="javascript"> <xsl:for-each select="msxsl:node-set($_ADItems)/Item"> var win = window.open("","_<xsl:value-of select="ADItemID" />","height=<xsl:value-of select="$_adPosition/iHeightSize" />,width=<xsl:value-of select="$_adPosition/iWidthSize" />"); <xsl:choose> <xsl:when test="Flash"> win.document.write('<xsl:value-of select="'<'" disable-output-escaping="yes"/>OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" VIEWASTEXT<xsl:value-of select="'>'" disable-output-escaping="yes"/><xsl:value-of select="'<'" disable-output-escaping="yes"/>PARAM NAME="Movie" VALUE="<xsl:value-of select="Flash" />"<xsl:value-of select="'>'" disable-output-escaping="yes"/><xsl:value-of select="'<'" disable-output-escaping="yes"/>PARAM NAME="Src" VALUE="<xsl:value-of select="Flash" />"<xsl:value-of select="'>'" disable-output-escaping="yes"/><xsl:value-of select="'<'" disable-output-escaping="yes"/>PARAM NAME="Quality" VALUE="High"<xsl:value-of select="'>'" disable-output-escaping="yes"/><xsl:value-of select="'<'" disable-output-escaping="yes"/>/OBJECT<xsl:value-of select="'>'" disable-output-escaping="yes"/>'); </xsl:when> <xsl:when test="Image"> <xsl:if test="Href!=''"> win.document.write("<xsl:value-of select="'<'" disable-output-escaping="yes"/>a href='<xsl:value-of select="Href"/>'<xsl:value-of select="'>'" disable-output-escaping="yes"/>"); </xsl:if> win.document.write("<xsl:value-of select="'<'" disable-output-escaping="yes"/>img border=0 src=<xsl:value-of select="Image" /><xsl:value-of select="'>'" disable-output-escaping="yes"/>"); <xsl:if test="Href!=''"> win.document.write("<xsl:value-of select="'<'" disable-output-escaping="yes"/>/a<xsl:value-of select="'>'" disable-output-escaping="yes"/>"); </xsl:if> </xsl:when> <xsl:otherwise> <xsl:if test="Href!=''"> win.document.write("<xsl:value-of select="'<'" disable-output-escaping="yes"/>a href='<xsl:value-of select="Href"/>'<xsl:value-of select="'>'" disable-output-escaping="yes"/>"); </xsl:if> win.document.write("<xsl:value-of select="Text" />"); <xsl:if test="Href!=''"> win.document.write("<xsl:value-of select="'<'" disable-output-escaping="yes"/>/a<xsl:value-of select="'>'" disable-output-escaping="yes"/>"); </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> </script> </xsl:if> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID)]"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <xsl:if test="cFileType='application/x-shockwave-flash'"> <Flash><xsl:choose> <xsl:when test="cFileUrl"> <xsl:value-of select="cFileUrl" /> </xsl:when> <xsl:otherwise>/ADManager/GetFile.aspx?type=3&id=<xsl:value-of select="iADItemID" /> </xsl:otherwise> </xsl:choose> </Flash> </xsl:if> <xsl:if test="cFileType='image/jpg'"> <Image><xsl:choose> <xsl:when test="cFileUrl"> <xsl:value-of select="cFileUrl" /> </xsl:when> <xsl:otherwise>/ADManager/GetFile.aspx?type=2&id=<xsl:value-of select="iADItemID" /> </xsl:otherwise> </xsl:choose> </Image> </xsl:if> <xsl:if test="(not(cFileUrl) or cFileUrl='') and not(cFileName)"> <Text> <xsl:value-of select="cTitle" /> </Text> </xsl:if> <Href> <xsl:if test="cLink and cLink != ''">/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="cLink" />&id=<xsl:value-of select="iADItemID" /></xsl:if> </Href> </Item> </xsl:for-each> </xsl:template> </xsl:stylesheet> ---------------------------------MarqueeText.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/" exclude-result-prefixes="dyens msxsl xsl"> <xsl:import href="Comm.xslt"/> <xsl:output method="html" /> <xsl:param name="_direction" select="'left'" /> <xsl:template match="/"> <xsl:call-template name="ADPosition"></xsl:call-template> </xsl:template> <!--广告位--> <xsl:template name="ADPosition"> <xsl:variable name="_adPosition" select="/NewDataSet/Table[iPositionID]" /> <!--DIV开始--> <xsl:element name="div"> <xsl:attribute name="style"> <xsl:value-of select="concat('position:relative;overflow:hidden;width:', $_adPosition/iWidthSize, 'px;height:', $_adPosition/iHeightSize, 'px')" /> </xsl:attribute> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <xsl:if test="count(msxsl:node-set($_ADItems)/Item) > 0"> <xsl:element name="MARQUEE"> <xsl:attribute name="HSPACE">10</xsl:attribute> <xsl:attribute name="VSPACE">10</xsl:attribute> <xsl:attribute name="BEHAVIOR">SCROLL</xsl:attribute> <xsl:attribute name="SCROLLAMOUNT">5</xsl:attribute> <xsl:attribute name="SCROLLDELAY">200</xsl:attribute> <xsl:attribute name="height">100%</xsl:attribute> <xsl:attribute name="DIRECTION"><xsl:value-of select="$_direction" /></xsl:attribute> <xsl:for-each select="msxsl:node-set($_ADItems)/Item"> <xsl:if test="$_direction='left'"> <xsl:choose> <xsl:when test="Href != ''"> <a href="{Href}"><xsl:value-of select="Text" /></a> </xsl:when> <xsl:otherwise> <xsl:value-of select="Text" /> </xsl:otherwise> </xsl:choose> <!--该行为全角空格--> </xsl:if> <xsl:if test="$_direction='up'"> <xsl:choose> <xsl:when test="Href != ''"> <a href="{Href}"><xsl:value-of select="Text" /></a> </xsl:when> <xsl:otherwise> <xsl:value-of select="Text" /> </xsl:otherwise> </xsl:choose> <br/> </xsl:if> </xsl:for-each> </xsl:element> </xsl:if> </xsl:element> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID)]"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <Text><xsl:value-of select="cTitle" /></Text> <Href> <xsl:if test="cLink and cLink != ''">/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="cLink" />&id=<xsl:value-of select="iADItemID" /></xsl:if> </Href> </Item> </xsl:for-each> </xsl:template> </xsl:stylesheet> ------------------------------------FloatAD.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/" exclude-result-prefixes="dyens msxsl xsl"> <xsl:import href="Comm.xslt"/> <xsl:output method="html" /> <xsl:template match="/"> <xsl:call-template name="ADPosition"></xsl:call-template> </xsl:template> <!--广告位--> <xsl:template name="ADPosition"> <xsl:variable name="_adPosition" select="/NewDataSet/Table[iPositionID]" /> <xsl:variable name="_ADItems"> <xsl:call-template name="GetADItems" /> </xsl:variable> <xsl:if test="count(msxsl:node-set($_ADItems)/Item) > 0"> <script language="javascript"> <xsl:call-template name="GetScriptForFloat" /> <xsl:for-each select="msxsl:node-set($_ADItems)/Item"> new randFly("<xsl:value-of select="Image" />", 2, 35 <xsl:if test="Href!=''">,"window.open('<xsl:value-of select="Href"/>')"</xsl:if>); </xsl:for-each> </script> </xsl:if> </xsl:template> <!--获取指定广告位内广告项--> <xsl:template name="GetADItems"> <xsl:for-each select="/NewDataSet/Table[not(iPositionID) and cFileType='image/jpg']"> <Item> <ADItemID><xsl:value-of select="iADItemID" /></ADItemID> <Image><xsl:choose> <xsl:when test="cFileUrl"> <xsl:value-of select="cFileUrl" /> </xsl:when> <xsl:otherwise>/ADManager/GetFile.aspx?type=2&id=<xsl:value-of select="iADItemID" /> </xsl:otherwise> </xsl:choose> </Image> <Text> <xsl:value-of select="cTitle" /> </Text> <Href> <xsl:if test="cLink and cLink != ''">/ADManager/ADManager.UI/ADControler.aspx?href=<xsl:value-of select="cLink" />&id=<xsl:value-of select="iADItemID" /></xsl:if> </Href> </Item> </xsl:for-each> </xsl:template> <xsl:template name="GetScriptForFloat"> <![CDATA[ var randFlyCount = 0; var randFlyCollection = new Array(); randFly.pause = function(){} //定义漂浮广告对象; function randFly(fileUrl, flyAmount, flyDelay, openUrl) { this._ID = randFlyCount++; this.objPoint = fileUrl; this._amount = flyAmount; this._delay = flyDelay; this._command = openUrl; this._setTime; this._dirX; this._dirY; this._stepX; this._stepY; //实例启动函数; this.init = function() { var srcFile = this.objPoint; this.objPoint = document.createElement("<img src='" + srcFile + "' style='cursor:hand'/>"); document.body.appendChild(this.objPoint);//生成广告html实体; with(this.objPoint) { style.position = "absolute"; style.cursor = "hand"; style.top = (document.body != null)? (document.body.clientHeight - offsetHeight) / 2 : 0; style.left = (document.body != null)? (document.body.clientWidth - offsetWidth) / 2 : 0; setAttribute("cID",this._ID);//自定义属性; setAttribute("reflectClass",this);//自定义属性; attachEvent("onclick",new Function(this._command)); attachEvent("onmouseover",this.pause);//设置鼠标停留事件; attachEvent("onmouseout",this.restart);//设置鼠标移出事件; } this._stepX = this._amount; this._stepY = this._amount; this._dirX = rBool(); this._dirY = rBool(); randFlyCollection.push(this); this.start(); } //方向调整函数; this.start = function() { if(this._dirX == true) { if(this.objPoint.offsetLeft + this._stepX + this.objPoint.offsetWidth < document.body.scrollLeft+document.body.clientWidth) { this.objPoint.style.left = this.objPoint.offsetLeft + this._stepX; } else { this.objPoint.style.left = this.objPoint.offsetLeft - this._stepX this._dirX = false; } } else { if(this.objPoint.offsetLeft - this._stepX > 0) { this.objPoint.style.left = this.objPoint.offsetLeft - this._stepX; } else { this.objPoint.style.left = this.objPoint.offsetLeft + this._stepX; this._dirX = true; } } if(this._dirY == true) { if(this.objPoint.offsetTop + this._stepY + this.objPoint.offsetHeight < document.body.scrollTop+document.body.clientHeight) { this.objPoint.style.top = this.objPoint.offsetTop + this._stepY; } else { this.objPoint.style.top = this.objPoint.offsetTop - this._stepX this._dirY = false; } } else { if(this.objPoint.offsetTop - this._stepY > 0) { this.objPoint.style.top = this.objPoint.offsetTop - this._stepY; } else { this.objPoint.style.top = this.objPoint.offsetTop + this._stepY; this._dirY = true; } } this._setTime = setTimeout("randFlyCollection["+this.objPoint.cID+"].start()",this._delay); } this.pause = function() { clearTimeout(event.srcElement.reflectClass._setTime); } this.restart = function() { event.srcElement.reflectClass.start(); } this.init(); } function rBool() { return (Math.random() > 0.5)? true : false; } ]]> </xsl:template> </xsl:stylesheet>
/** * 文件名称:ADPosition.cs * 描 述 : * 版 权 :东宇软件公司 * 公 司 :东宇软件公司 * 作 者 :杨林 * 日 期 :2008-08-15 * 版 本 : * 文件修改日志: * 1. 日期:格式(2000-03-01) * 修 改 人: * 修改内容: * 版 本: */ using System; using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; namespace dysoft.ADManager.Model { public class ADPosition { private dysoft.ADManager.DataAccess.ADPositionDAO oPosition; public ADPosition() { this.oPosition = new dysoft.ADManager.DataAccess.ADPositionDAO(); } public string Add(dysoft.ADManager.Util.ADPositionInfo oEntity) { string strResult = ""; try { this.oPosition.Insert(oEntity); } catch(System.Data.SqlClient.SqlException ex) { strResult = dysoft.ADManager.Util.MsgFilter.FilterExceptionMsg(ex); } return strResult; } public string Edit(dysoft.ADManager.Util.ADPositionInfo oEntity) { string strResult = ""; try { this.oPosition.Update(oEntity); } catch(System.Data.SqlClient.SqlException ex) { strResult = dysoft.ADManager.Util.MsgFilter.FilterExceptionMsg(ex); } return strResult; } public string Remove(int[] id) { string strResult = ""; try { strResult = this.oPosition.Delete(id); } catch(System.Data.SqlClient.SqlException ex) { strResult = dysoft.ADManager.Util.MsgFilter.FilterExceptionMsg(ex); } return strResult; } public string Disabled(int[] id) { string strResult = ""; try { strResult = this.oPosition.Disabled(id); } catch(System.Data.SqlClient.SqlException ex) { strResult = dysoft.ADManager.Util.MsgFilter.FilterExceptionMsg(ex); } return strResult; } public string Enabled(int[] id) { string strResult = ""; try { this.oPosition.Enabled(id); } catch(System.Data.SqlClient.SqlException ex) { strResult = dysoft.ADManager.Util.MsgFilter.FilterExceptionMsg(ex); } return strResult; } public dysoft.ADManager.Util.ADPositionInfo GetADPositions() { try { return this.oPosition.QueryADPositions(); } catch(System.Data.SqlClient.SqlException) { return null; } } public dysoft.ADManager.Util.ADPositionInfo GetADPositions(int iProductID, int iSystemID, bool bDisabled) { try { return this.oPosition.QueryADPositions(iProductID, iSystemID, bDisabled); } catch(System.Data.SqlClient.SqlException) { return null; } } public dysoft.ADManager.Util.ADPositionInfo GetADPositionByID(int id) { try { return this.oPosition.QueryADPositionByID(id); } catch(System.Data.SqlClient.SqlException) { return null; } } public string GetRefScript(int iPositionID, bool bPreview) { try { System.Data.DataSet dtsResult = this.oPosition.QueryADPositionDetail(iPositionID, bPreview); string strXslt = System.Text.Encoding.GetEncoding("gb2312").GetString(dtsResult.Tables[0].Rows[0]["gAttach"] as byte[]); System.Xml.XmlDocument xsltDoc = new XmlDocument(); xsltDoc.LoadXml(strXslt); XslTransform oXslt = new XslTransform(); oXslt.Load(xsltDoc.CreateNavigator(), new System.Xml.XmlUrlResolver(), this.GetType().Assembly.Evidence); System.Xml.XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dtsResult.GetXml()); System.Text.StringBuilder oSBuder = new System.Text.StringBuilder(); System.IO.StringWriter oSW = new System.IO.StringWriter(oSBuder); //Create the XsltArgumentList. XsltArgumentList xslArg = new XsltArgumentList(); xslArg.AddParam("_bPreview", "", bPreview ? 1 : 0); //xslArg.AddParam("_iID", "", 6); oXslt.Transform(xmlDoc, xslArg, oSW, new System.Xml.XmlUrlResolver()); String strScript = oSBuder.ToString(); oSW.Close(); return strScript; } catch(System.Data.SqlClient.SqlException) { return ""; } catch(System.Xml.XmlException ex) { return ""; } } public string GetRefScript(int iPositionID, int iADID, bool bPreview) { try { System.Data.DataSet dtsResult = this.oPosition.QueryADPositionDetail(iPositionID, bPreview); string strXslt = System.Text.Encoding.GetEncoding("gb2312").GetString(dtsResult.Tables[0].Rows[0]["gAttach"] as byte[]); System.Xml.XmlDocument xsltDoc = new XmlDocument(); xsltDoc.LoadXml(strXslt); XslTransform oXslt = new XslTransform(); oXslt.Load(xsltDoc.CreateNavigator(), new System.Xml.XmlUrlResolver(), this.GetType().Assembly.Evidence); System.Xml.XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dtsResult.GetXml()); System.Text.StringBuilder oSBuder = new System.Text.StringBuilder(); System.IO.StringWriter oSW = new System.IO.StringWriter(oSBuder); //Create the XsltArgumentList. XsltArgumentList xslArg = new XsltArgumentList(); xslArg.AddParam("_bPreview", "", bPreview ? 1 : 0); xslArg.AddParam("_iID", "", iADID); oXslt.Transform(xmlDoc, xslArg, oSW, new System.Xml.XmlUrlResolver()); String strScript = oSBuder.ToString(); oSW.Close(); return strScript; } catch(System.Data.SqlClient.SqlException) { return ""; } catch(System.Xml.XmlException) { return ""; } } } }
南来地,北往的,上班的,下岗的,走过路过不要错过!
======================个性签名=====================
之前认为Apple 的iOS 设计的要比 Android 稳定,我错了吗?
下载的许多客户端程序/游戏程序,经常会Crash,是程序写的不好(内存泄漏?刚启动也会吗?)还是iOS本身的不稳定!!!
如果在Android手机中可以简单联接到ddms,就可以查看系统log,很容易看到程序为什么出错,在iPhone中如何得知呢?试试Organizer吧,分析一下Device logs,也许有用.