So, your application is crashing and it is crashing in?the?bad way. After spending hours of debugging and trying different things you figured out that this is this Xslt stylesheet that causes all the problems. How come? XslCompiledTransform is a compiler. It’s a bit different from C# or VB.NET compilers because it runs at runtime but the result of the compilation is basically the same – IL (Intermediate Language) code. One of disadvantages of running compilation at runtime is that compilation issues may have impact on the running application. In the “offline” scenario compiler would just return an error (the one I hate the most is “Internal Compiler Error” – still it will not affect my app at runtime ?? at worst there is no app). So, compilation may be one source of problems. The other source of problems can be the IL code the stylesheet was compiled to. Here there is not much difference between code generated from Xslt, C# or VB. In any case it is easy to write a program that compiles correctly but misbehaves at runtime (bugs anyone?). Let’s take a look at two most common unexpected exceptions you may hit when working with XslCompiledTransform and ways to resolve them.
分类: 编程
与编程有关的种种
《高效 XML》第4部分 Let me project this (Xml file) for you
Xml is ubiquitous. No doubt about it. It is being used almost everywhere and almost by everyone. This includes places where huge amounts of data are being processed. This means xml files (or streams) used there are also huge. And the bigger the Xml file the harder it is to process. The two biggest problems are:
- You need to query the document with a couple of XPath expressions or transform it with an Xslt file but the document is too big to be even loaded (the rule of thumb is that an Xml document needs up to 5 times memory of its size on the disk). When you try to load the document you get OutOfMemoryException and that’s about where your Xml processing ends.
- You are able to load the document but all the queries or transformations are sloooow (and I assume it’s not because the queries or Xslt stylesheets are poorly written – if you are not sure see Effective Xml Part 3)
《高效 XML》第3部分 Didn’t you say XslCompiledTransform was fast?
“XslCompiledTransform is fast.”
“Really?”
“Yeah, XslCompiledTransform is fast… if used correctly.”
Indeed, depending on how you use XslCompiledTransform API your transformations can be really fast or not-that-fast (to say the least). The key to understanding where this difference comes from is to understan what XslCompiledTransform.Load() method actually does. The name of the method indicates that it is just used to load Xslt stylesheets. In reality the method does much more than this. It not only loads the Xslt stylesheet but it also compiles it to IL (Intermediate Language). Yes, after the stylesheet has been “loaded” somewhere there in memory is the real code built based on the provided stylesheet. Generating this code (i.e. “loading” the stylesheet) is costly but it allows for fast transformations – when you start a transformation in your app it no longer deals with the stylesheet, it just invokes the code the Xslt stylesheet was compiled to.
继续阅读《高效 XML》第3部分 Didn’t you say XslCompiledTransform was fast?
《高效XML》第2部分 How to kill the performance of an app with XPath…
XPath expressions are pretty flexible. This flexibility allows for very creative ways of using XPath. Unfortunately some of them are suboptimal and cause bad performance of apps. This is especially visible in Xslt transformations where stylesheets contains tens if not hundreds of XPath expressions. Here is the list of the most common bad practices (or even anti-patterns) I have seen:
继续阅读《高效XML》第2部分 How to kill the performance of an app with XPath…
LINQ TO XML 笔记
来源:http://msdn.microsoft.com/zh-cn/library/bb387098.aspx
什么是LINQ to XML?
LINQ to XML 是一种启用了 LINQ 的内存 XML 编程接口,使用它,可以在 .NET Framework 编程语言中处理 XML。
LINQ to XML 将 XML 文档置于内存中,这一点很像文档对象模型 (DOM)。?您可以查询和修改 XML 文档,修改之后,可以将其另存为文件,也可以将其序列化然后通过 Internet 发送。?但是,LINQ to XML 与 DOM 不同:它提供一种新的对象模型,这是一种更轻量的模型,使用也更方便,这种模型利用了 Visual C# 2008 在语言方面的改进。
LINQ to XML 最重要的优势是它与 语言集成查询 (LINQ) 的集成。?由于实现了这一集成,因此,可以对内存 XML 文档编写查询,以检索元素和属性的集合。?LINQ to XML 的查询功能在功能上(尽管不是在语法上)与 XPath 和 XQuery 具有可比性。?Visual C# 2008 集成 LINQ 后,可提供更强的类型化功能、编译时检查和改进的调试器支持。
LINQ to XML 的另一个优势是通过将查询结果用作?XElement?和?XAttribute?对象构造函数的参数,实现了一种功能强大的创建 XML 树的方法。?这种方法称为“函数构造”,利用这种方法,开发人员可以方便地将 XML 树从一种形状转换为另一种形状。 继续阅读LINQ TO XML 笔记
iebook Actionscript2.0 脚本
注:在插入的内页flash中,要想调用以下参数(或函数)或者自制按钮的自定义函数,请在舞台第一帧添加this._lockroot=false语句。——感谢zmaker的指导
转到封面 _root.Zine1.gotoCover()
转到目录 _root.Zine1.gotoContent()
转到封底 _root.Zine1.gotoBCover()
转到某页 _root.Zine1.gotopage(int(pageNumber)+1) (注:pageNumber 从0开始)
设置音量 _root.Zine1.setmusicvol(v) (注:取值范围0~100)
获取音量 _root.Zine1.getmusicvol()
转到上一页 _root.Zine1.prevpage()
转到下一页 _root.Zine1.nextpage()
当前页 _root.Zine1.getpage()
当前帧 _root.Zine1.getframeplayed()
总页数 _root.Zine1.getmaxpage()
全屏/1:1显示 _root.Zine1.screenfull()
最小化 _root.Zine1.minimize()
退出 _root.Zine1.exit();
单页宽度 _root.Zine1.getpageW();
单页高度 _root.Zine1.getpageH();
屏幕宽度 System.capabilities.screenResolutionX;
屏幕高度 System.capabilities.screenResolutionY;
隐藏底部版权 _root.Zine1.copy_mc.Copyright._visible=false
========================
iebook内页专用
获取深度 this._parent.getDepth();
获取角度 this._parent._rotation;
获取比例 this._xscale;
=====================
复制地址 _root.Zine1.AppCommand(“CopyUrl”, “”)
加载 ie搜索按钮 _root.Zine1.loadTool(“iesearch”, “iesearch.swf”)
加载在线交流按钮 _root.Zine1.loadTool(“comment”, “comment.swf”)
加载即时通信功能
var Info = _root.Zine1.getZineInfo(); if (Info.IM.toLowerCase() == "qq") { getURL (("tencent://message/?uin=" + Info.QQ) + "&Site=iebook.cn&Menu=yes"); } else { getURL ("msnim:chat?contact=" + Info.MSN); }
加载涂鸦按钮 _root.Zine1.loadTool(“booktag”, “booktag.swf”)
加载打印按钮 _root.Zine1.loadTool(“print”, “print.swf”)
加载帮助按钮 _root.Zine1.loadTool(“help”, “help.swf”)
加载设置按钮 _root.Zine1.loadTool(“config”, “config.swf”)
加载统计系统 _root.Zine1.loadTool(“count”, “count.swf”)
其他按钮
Question.swf 文件调查
recommend.swf
=====================
获取名称变量(赋值:caption)
_root.Zine1.getCaption() if (caption.type.toLowerCase() == "string") { this.caption_txt.autoSize = "left"; this.caption_txt.text = caption.value; bg._width = caption_txt._width + 10; bg._height = caption_txt._height; } else { bg._visible = false; caption_txt._visible = false; this.createEmptyMovieClip("logo", 0); eobj.onLoadInit = function (t) { t._y = 18 - t._height; }; mc_l.addListener(eobj); mc_l.loadClip(caption.value, this.logo); }
打开名称链接 getURL (caption.link, “_blank”);
获取版权信息 _root.Zine1.getCopyright()
获取版权链接 _root.Zine1.getCopyLink()
====================
on(rollOver){ _root.showalt("提示内容"); //显示提示信息 } on(releaseOutside,rollOut){ _root.hidealt();//隐藏提示信息 }
====================
内容定位
function reposmc(mc, bottom, right) { mc._x = mc._x + (right * (mag_w - 375)); mc._y = mc._y + (bottom * ((mag_h - 550) / 2)); } var comm1 = this.attachMovie("communicate", "comm1", -1); stop(); br.prve_b._visible = false; //上一页按钮不可见 var eobj = new Object(); eobj.Magflipover = function (target) { br.prve_b._visible = true; //上一页按钮可见 br.next_b._visible = true; //下一页按钮可见 if (_root.Zine1.getpage() == _root.Zine1.getmaxpage()) { br.next_b._visible = false; } if (_root.Zine1.getpage() == 0) { br.prve_b._visible = false; } }; _root.Zine1.addEventListener("Magflipover", eobj); if (_root.Zine1.getshowplaystate() == false) { bl.playstate.unloadMovie(); } var mag_w = _root.Zine1.getpageW(); var mag_h = _root.Zine1.getpageH(); reposmc(br, 2, 2); reposmc(bl, 2, 0); reposmc(tr, 0, 2); reposmc(iebookbq, 2, 0.5); reposmc(cpt, 2, 0.5); reposmc(hidenbt, 0, 2);
===============================================
zine1 有以下成员
ws: _level0.Zine1.ws
initmc: _level0.Zine1.initmc
bg: _level0.Zine1.bg
fullscreen: true
maxp: 4
bgimgurl:
sendreport: false
TemplateMode: true
screenH: 768
screenW: 1024
pageH: 650
pageW: 475
ShowInit: false
Shadowdepth: 26
ShadowFilter: 7
pagefengdis: false
showplaystate: false
AutoSpeedSetting: 6000
AutoEnabledSetting: false
BscreenH: 768
BscreenW: 1366
bs: [object Object]
toolscon2: _level0.Zine1.toolscon2
toolscon: _level0.Zine1.toolscon
toolbar1: _level0.Zine1.toolbar1 // 按钮
dface: [object Object]
mag: _level0.Zine1.mag
eObject: [object Object]
BaseURL:
toolsloader: [object Object]
dispatchQueue: [type Function]
dispatchEvent: [type Function]
removeEventListener: [type Function]
addEventListener: [type Function]
toolbar1: _level0.Zine1.toolbar1
initmc: _level0.Zine1.initmc
ws: _level0.Zine1.ws
timer: _level0.Zine1.timer
toolscon2: _level0.Zine1.toolscon2
toolscon: _level0.Zine1.toolscon
mag: _level0.Zine1.mag
copy_mc: _level0.Zine1.copy_mc // 版权
bg: _level0.Zine1.bg
===============================================
2013年11月16日
代码来源经典视频收藏版4
_root.online 电子杂志是否为在线版本
_root.getFLVPath(path) 获取FLV视频路径(此函数可能程序自带,或自定义函数);如:_root.getFLVPath(“1.flv”)
function getFLVPath(path){ return ("http://"+ path); }
video 为FLVPlayback组件
video 的事件
onClipEvent (construct){ autoPlay = true; autoRewind = true; autoSize = false; bufferTime = 1.000000E-001; contentPath = ""; isLive = false; maintainAspectRatio = true; skin = ""; skinAutoHide = false; totalTime = 0; volume = 100; }
video.bufferingBar = my_bufferingBar; //my_bufferingBar为用户定义的元件名 video.pauseButton = my_pauseButton; //同上 video.contentPath = _root.getFLVPath(_parent._parent.attachfile4); //参阅楼上 listenerObject = new Object(); listenerObject.ready = function (eventObject){ playpauseButton.gotoAndStop(2); if (video.width < 485){ video._x = (485 - video.width) / 2 + 0; } if (video.height < 270){ video._y = (270 - video.height) / 2 + 30; } }; listenerObject.complete = function (eventObject){ playpauseButton.gotoAndStop(1); }; video.addEventListener("ready", listenerObject); video.addEventListener("complete", listenerObject); /*----------------华丽的分割线------------------*/ listenerObject = new Object(); listenerObject.ready = function (eventObject){ ctr.playpauseButton.gotoAndStop(2); //ctr为影片剪辑,内含播放、暂停按钮 video.maintainAspectRatio = false; video.width = 485; video.height = 270; }; listenerObject.complete = function (eventObject){ ctr.playpauseButton.gotoAndStop(1); }; video.addEventListener("ready", listenerObject); video.addEventListener("complete", listenerObject);
如何执行添加到解决方案里的批处理文件
前不久重新做了系统,还没来得及装iebook超级精灵等软件,今天得空要装时,想起既然做了一个辅助工具了,干脆把iebook的安装、卸载功能集成进去,一来省去重新安装的烦恼,二来以后修改到iebook时,也不用重新生成安装包,可谓一举两得。
于是有了新版本 v1.1。
通过此次补充还学到了另一个知识。如何执行添加到解决方案里的批处理文件。有关链接参阅:http://wenwen.sogou.com/z/q170165608.htm
命令如下(tmp.bat为添加到解决方案里的批处理文件):
shell(“cmd /c tmp.bat”, AppWinStyle.Hide, True)
Flash Actionscript 2.0 学习笔记
鼠标有关
var someListener:Object=new Object()
someListener.onMouseMove=function(){}
Mouse.addListener(someListener)
Mouse.removeListener(someListener)
Mouse.hide()
Mouse.show()
xx._xmouse
xx._ymouse
是单击还是拖移?
检测前后鼠标位置