新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 计算机科学论坛XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → MSXML XSLT FAQ 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 9983 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: MSXML XSLT FAQ 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     admin 帅哥哟,离线,有人找我吗?
      
      
      
      威望:9
      头衔:W3China站长
      等级:计算机硕士学位(管理员)
      文章:5255
      积分:18407
      门派:W3CHINA.ORG
      注册:2003/10/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给admin发送一个短消息 把admin加入好友 查看admin的个人资料 搜索admin在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 点击这里发送电邮给admin  访问admin的主页 引用回复这个贴子 回复这个贴子 查看admin的博客楼主
    发贴心情 MSXML XSLT FAQ

    http://www.netcrucible.com/xslt/msxml-faq.htm

    Unofficial MSXML XSLT FAQ

    Introduction

    When Internet Explorer 5.0 was first shipped in 1998, Microsoft shipped an implementation of XSL that was based on the current working draft of XSL at that time.  Millions of copies of this XML/XSL processor were burned on CDs and were installed on systems all around the world.  Since then, the XSLT specification changed very significantly (even the namespace changed!) and was finalized.  So the situation as it is today (12/4/2000) is that there are millions of copies of a parser out there which does not (by default) support the latest XSLT specification.  It is quite common for people to write to the xslt-list asking for information about why some operation does not work in Internet Explorer 5.0.  Although there have been updates to the MSXML parser to make it more current, many people are not aware that they can download these and do not realize that they are using the older, less compliant processor.  While the XSLT community appreciates the way that IE5 has exposed many more people to the cross-platform wonders of XSL, there is quite a bit of consternation caused by frequent questions having a root in the fact that IE5 shipped before the specification was mature.

    This is not meant to be a replacement or even a subset of the excellent XSL FAQ that exists.  It is rather meant to be a simple URL that people on xslt-list can refer individuals having trouble getting started with XSLT and IE.  If you are reading this, there is a good chance you were referred here from the list :-).

    Questions

    Why do my transforms fail using IE?
    How do I run XSLT transforms automatically from code?
    How do I run XSLT transforms within Internet Explorer?
    Why do I need to use a different XSLT namespace with Internet Explorer?
    How do I install the updated MSXML on my machine?
    I know I have installed the most recent MSXML processor; why is my application not using it?
    When will Microsoft ship a 100% compliant XSLT processor?
    Does IE5.5 include a newer XSLT processor?
    The newest MSXML processors available for download say that they are not supported.  How can I use these if they are not supported? [Obsolete]
    Why is the MSDN online documentation for XSL so different from the W3C XSLT specification?
    Where does Microsoft provide documentation about compliance of MSXML?
    How can I call MSXML from the command line to do batch processing of XSLT?
    Why doesn't MSXML support XML Schema (XSD) or, Why did Microsoft make their own version of schema (XDR)?
    What do I do if I already wrote lots of XSL using the old IE version of XSL?
    Why do I sometimes have problems including a document from a URL (or what's this talk about async vs. synch)?
    When will server-side HTTP be reliable under heavy load?
    I need to use the node-set() extension function, but MSXML doesn't seem to have it.
    How do I dynamically change the stylesheet associated with my XML file from code?
    How does Internet Explorer format XML files in a collapsible view, and how can I modify this behavior?
    Answers

    1.  Why do my transforms fail using IE (or using my custom application)?

    Before you send a question to the XSLT list, it is best to check a few things:

    Make sure you have installed the most recent MSXML processor.  If you are using the parser that shipped with IE5 (or IE5.5), then you are using a parser that was based on the early working drafts, and does not much resemble the XSLT of today.  The XSLT list discusses today's version of XSLT, and you should probably be using it, too.  People on the list are not very friendly about helping with the old version, since it is so much different.  If you don't remember installing the latest processor, you probably didn't install it.  For instructions on installing, see the question "How do I install the updated MSXML?"  Chris Bayes provides an MSXML Version Sniffer can tell you what version you have installed.
    Check to make sure you are actually using the latest processor.  It is possible that you are still using the old processor, even if you have installed the newer version of MSXML.  The first thing you should do is look at the top of this page, where there should be a message telling you what version of MSXML you have installed on your machine.  Another way to make sure you are using the correct processor is to try running the transform from the XSLT Test Tool.  If your transform works in this tool, but not in your application, chances are you are using the old processor.  See the question "I know I have installed the most recent MSXML" to see how to fix your application.
    Check to make sure that the transform works in other XSLT processors.  Again, the XSLT Test Tool is a good way to do this.  You can test your transform against MSXML and any other XSLT processors that you have installed.  I like to use Saxon and Xt.  Using the other processors can often give you some very useful information about why your transform does not work as you expect, and knowing if any other parsers can do the transform correctly will be a key piece of information that will help others answer your questions.  If you are testing only against the MSXML parsers, the XSL Debugger has many more features than the XSLT Test Tool and is a better option.  There is also a tool called XPath Visualizer, which is very helpful when debugging XPath issues within your transform.
    Once you have checked these things, you will have much better information to ask your question.


    2.  How do I run XSLT transforms automatically from code?

    Here is some code that calls a transform against the recent versions of MSXML:

            Dim xmlSource As Object
            Dim xmlXForm As Object
            Set xmlSource = CreateObject("MSXML2.DOMDocument")
            Set xmlXForm = CreateObject("MSXML2.DOMDocument")
            
            xmlSource.validateOnParse = True
            xmlXForm.validateOnParse = True
            xmlSource.async = False
            xmlXForm.async = False
            
            xmlSource.loadXML Text3.Text ' This loads the text that I want to transform
            If Err.Number <> 0 Then
                strErr = Err.Description & vbCrLf
                strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
                MsgBox strErr, vbCritical, "Error loading the XML"
                GoTo bail
            End If
            
            xmlXForm.loadXML Text1.Text ' This loads the XSLT transform
            If Err.Number <> 0 Then
                strErr = Err.Description & vbCrLf
                strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
                MsgBox strErr, vbCritical, "Error loading the Transform"
                GoTo bail
            End If
             
            Text2.Text = xmlSource.transformNode(xmlXForm) ' This transforms the data in xmlSource
            If Err.Number <> 0 Then
                strErr = Err.Description & vbCrLf
                strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
                MsgBox strErr, vbCritical, "Error executing the Transform"
                GoTo bail
            End If
            
            Set xmlSource = Nothing
            Set xmlXForm = Nothing

    The code above is written in VB, but you can write using Java, JScript, VBScript, PerlScript, C++, or any other language that supports COM.  The important thing about the above code sample is that we are using the CreateObject("MSXML2.DOMDocument") instead of CreateObject("MSXML.DOMDocument").  Using "MSXML2" ensures that you call the newer XSLT processor, and not the working draft version from 1998.  This example should also show you how to get detailed error information if your transform fails.  One thing to note: if you are transforming unstructured data (non-XML), then you will probably want to set xmlSource.ValidateOnParse=False in the above example.  You probably don't want it to be telling you that your document is not well-formed XML when you already know that and don't care!

    3.  How do I run XSLT transforms within Internet Explorer?

    As long as your XML file refers to the appropriate .xslt stylesheet, it should render in IE5.  If you are running side-by-side installation of MSXML, IE will use the old XSLT processor.  To unregister the old processor and tell IE to use the new one, type the following four commands at a command prompt:

    regsvr32 msxml3.dll
    xmlinst

    If you would like to unregister the older version of the processor, type the following sequence of commands instead:

    xmlinst -u
    regsvr32 -u msxml.dll
    regsvr32 msxml3.dll
    xmlinst
    Note: In the final release, xmlinst.exe is a separate download from MSDN, and does not come with the MSXML download.  You can download xmlinst.exe here.

    More information about installing for replace mode is found in the online documentation that comes with the updated parsers.  You may also wish to download the "Internet Explorer Tools for Validating XML and Viewing XSLT Output".

    4.  Why do I need to use a different XSLT namespace with Internet Explorer?

    Actually, you don't!  You should use the standard xmlns:xsl="http://www.w3.org/1999/XSL/Transform".  If your code is complaining when you try to use this namespace, it is likely that you are using the old version of the MSXML processor (which was developed before the above namespace was even dreamed up).

    If you have older style sheets and do not wish to convert them to the new format, you can also use the old namespace declaration xmlns:xsl="http://www.w3.org/TR/WD-xsl".

    5.  How do I install the updated MSXML on my machine?

    First

    First, try pointing your browser to the magic install tool provided by Chris Bayes.  If this does not work, try the following manual steps:
    Browse to the MSDN XML Site, and download the final release.  Just double-click the file to install.   
    The latest parser will install side-by-side with your existing parser.  In this configuration, you will be able to easily run transforms with code, but you may have trouble getting Internet Explorer to use the new processor.
    If you want to install the new XSL processor to be used by default with Internet Explorer, follow the steps outlined in "How do I run XSLT transforms within Internet Explorer?".
    To get the latest documentation, including XSLT/XPath reference, download the XML SDK Setup File and double-click.
    The latest documentation will be in a .chm file in the directory where the SDK is installed.  By default, this file location is <C:\Program Files\Microsoft XML Parser SDK\Docs\xmlsdk30.chm>.
    There is also a code-signed package that allows you to install MSXML3 to people's machines through their web browser.  For instructions on how to create a web page that installs MSXML3, see http://msdn.microsoft.com/xml/articles/msxmlcabfile.asp.

    Note: The MSXML3 parser is a binary COM Object written for high performance on the Windows platform and is not written in Java.  The old MSXML-Java parser is no longer maintained.

    Note: If you have trouble executing the install files, they can also be loaded using WinZip.

    Note: The installation files above use the Microsoft Installer.  If your machine does not have Windows Installer, you can download it here.

    Note: If you want to try another way to download and install MSXML3, you can try the automated install utility I wrote.  This is a very crude tool, but usually works.  It downloads and installs 8 other XSLT Processing tools and the XSLT test tool as well.

    6.  I know I have installed the most recent MSXML processor; why is my application not using it?

    If you are calling your transform from within some programming language, this is probably because you are not using "MSXML2.DOMDocument" in your call to CreateObject().  See the question about calling transforms from code for an example using the correct call.  If you are attempting to view the XSLT transform directly from Internet Explorer, you have probably installed the newest MSXML in side-by-side mode.

    7.  When will Microsoft ship a 100% compliant XSLT processor?

    The final release of MSXML3 attempts to be 100% compliant.  This release passes the OASIS conformance test suite 100%, and is one of the most conformant engines available.  It is always possible that there are conformance bugs.

    8.  Does IE5.5 include a newer XSLT processor?

    No.  Internet Explorer 5.5 still ships with the older processor.  If you want to use an implementation of the current XSLT specification, you will need to install it.  The next versions of Internet Explorer and Windows will come with the newest XSLT processor included.

    9.  The newest MSXML processors available for download say that they are not supported.  How can I use these if they are not supported? [Obsolete]

    The release version of MSXML3 is now available and is fully supported.

    10.  Why is the MSDN online documentation for XSL so different from the W3C XSLT specification?

    You are probably looking at the wrong documentation.  The MSDN Online Library shows the documentation for the XSL processor that shipped with IE5 long before the XSLT specification was complete.  You need to install the XML SDK for the updated MSXML to get the updated documentation.  The updated XSLT reference will be installed as <C:\Program Files\Microsoft XML Parser SDK\Docs\xmlsdk30.chm> on your hard drive.  You can double-click this file to view the documentation, including full disclosure about level of conformance.  MSDN will be updated soon to reflect the new release of MSXML3.

    MSDN now has an interactive visual tool for learning the W3C XSLT and XPath.

    11.  Where does Microsoft provide documentation about compliance of MSXML?

    Each of the new releases of the MSXML parsers have a bug listing page which describes all known problems with that version.  Bugs listed here can include things typically thought of as coding mistakes, or areas that are not fully implemented.  In addition, if you have installed the documentation for the latest MSXML, you can read full conformance disclosure under the section "XSLT Developer's Guide\XSLT and XPath Conformance Notes".  Finally, the VBXML community maintains some pretty charts showing compliance of various versions of MSXML.  It is possible that there are bugs which have not been discovered with the current MSXML parsers, and it is also possible that some un-implemented part of the specification is not clearly documented.  Contrary to popular opinion, Microsoft does not want to "hide" information about MSXML compliance.  If you find a bug or implementation point that is not clearly documented, please send e-mail to Microsoft or to me (or better yet, both) so that the documentation can be updated.

    12.  How can I call MSXML from the command line to do batch processing of XSLT?

    There is now a command-line utility with source code available that allows fast command-line processing of XSLT.  Since MSXML is a COM object, you can write any .vbs, .js or other Windows Scripting Host (WSH) file to launch MSXML from the command line.  Ken Holman provides a comprehensive treatment of calling MSXML from command-line script to supplement the book "Practical Transformation Using XSLT and XPath".  Another option is to use the command-line syntax of the XSLT Test Tool or write your own executable wrapper.

    13.  Why doesn't MSXML support XML Schema (XSD) or, Why did Microsoft make their own version of schema (XDR)?

    XML-Schema efforts are continuing, and as of this writing (12/5/2000), XML-Schema is not finalized.  Microsoft has committed to support XML Schema when it becomes a full W3C recommendation.  Before XML-Schema efforts began, a number of companies developed the XML-Data specification.  When it became apparent that XML-Schema would supercede XML-Data, Microsoft wanted to support XML-Schema, but needed to ship product without waiting for standards efforts to continue.  To this end, XML-Data Reduced was developed as a minimal subset of XML-Data that was guaranteed to be compatible with XSL-Schema as it developed.  Current Microsoft XML parsers will validate documents against an XDR schema, and will support XSD when it is released.  The released MSXML3 uses XDR, but beta products such as the .NET framework SDK are already using XSD.  MSXML4 will use XSD.  In addition, tools to automatically convert XDR to XSD are now provided.  In fact, the conversion is accomplished through an XSLT stylesheet.  If you would like a conversion stylesheet that converts XDR to the latest XSD, you can get it at http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/539/msdncompositedoc.xml.

    14.  What do I do if I already wrote lots of XSL using the old IE version of XSL?

    If you would like to upgrade XSL stylesheets based on the earlier working draft to be compliant with the final XSLT specification, you can use the XSL to XSLT Converter available at MSDN.

    15.  Why do I sometimes have problems loading or including a document from a URL (or what's this talk about async vs. synch)?

    If you attempt to load an XMLDOM using the loadXML() method, the default behavior of the method is to load asynchronously.  This means that the DOM starts loading, and immediately returns control to you.  Unfortunately this means that you may attempt to use the DOM before it is loaded, resulting in annoying errors.  There are two things you can do to prevent this situation.  First, you can always tell the DOM to load synchronously (that is, wait for the document to finish loading before moving on to the next line of code) by setting the property async = False.  This is how the load is accomplished in the code sample here.  If you want the DOM to load asynchronously, you can always check to make sure that the property readyState = True before reading the DOM.

    16.  When will server-side HTTP in XML be reliable under heavy load?

    The final MSXML release has changed the HTTP loaders for SAX and DOM to be safe under heavy server load.  You must explicitly tell your code to use the new server-safe loader, as described here.  This link also includes a utility that allows you to configure the XML HTTP to transfer through a proxy server.  In order to make sure that no backward-compatible issues would exist, you will need to perform XMLHTTP loads as before, but using new objects.  Instead of using CreateObject("MSXML2.XMLHTTP") you will use CreateObject("MSXML2.ServerXMLHTTP").  If using the MSXML2.DOMDocument load() method, use code like the following (note the new call to setProperty()):

    Dim xmldoc
    Set xmldoc = CreateObject("MSXML2.DOMDocument")
    xmldoc.async = false
    xmldoc.setProperty("ServerHTTPRequest", true)
    xmldoc.load("http://machinename/path/file.xml")

    17.  I need to use the node-set() extension function, but MSXML doesn't seem to have it.

    It's there!  MSXML originally treated everything as a node-set, thus no extension function. Most other processors have a node-set extension function (which is how Saxon does things). There is talk of having the next XSLT spec formally require that everything be a node set by default. Now, since all processors besides MSXML require you to explicitly convert the RTF to a node-set first, and since MSXML didn't have a node-set function (node-set isn't in the spec) the finally released MSXML3 contains msxsl:node-set(string).

    18.  How do I dynamically change the client-side (for Internet Explorer) stylesheet associated with my XML file from code?

    Check out the XML/XSL Viewer sample on MSDN.  Chris Bayes has released a Power Toy utility that you can download from his XML Portal.  Also, see the next question if you are interested in the default XSL stylesheet used to display raw XML files in the browser.

    19.  How does Internet Explorer format XML files in a collapsible view, and how can I modify this behavior?

    For XML files that do not have a stylesheet associated, Microsoft Internet Explorer uses a default XSL stylesheet to create a DHTML rendering of the XML file.  Depending on which version of MSXML you are using, you can browse to either res://msxml3.dll/DEFAULTSS.xsl or res://msxml.dll/DEFAULTSS.xsl.  The res:// URN format indicates that the XSL file is compiled as a resource directly into the dll.  If you have a binary resource editor (such as the one included with Visual C++), you can edit the XSL directly inside the MSXML dll and save back into the binary file.  Alternately, you can start with a copy of the stylesheet from http://msdn.microsoft.com/xml/samples/defaultss/defaultss.xsl.


    Joshua Allen <joshuaa@netcrucible.com>
    Last Update: 1/30/2001


    --------------------------------------------------------------------------------

    Change History:

    2/11/2001 - Pointer to new detect sniffer, vbxml.com
    2/11/2001 - Pointers to .cab file distribution and xdr-xsd conversion
    1/30/2001 - Remove autodetect to fix (and hopefully add .cab pointers)
    1/22/2001 - Autodetect MSXML version, thanks Jarno Elovirta
    12/25/2000 - Added line numbers
    12/4/2000 - Some changes to reference released version of MSXML3
    12/4/2000 - node-set() update, thanks to Gavin Bong
    10/28/2000 - setProperties() example on Server-side XML
    10/25/2000 - IE5 XML Stylesheet, thanks Jarno Elovirta
    10/25/2000 - More info on server-side XMLHTTP
    10/7/2000 - Added information about the new secret location of xmlinst.exe.
    10/3/2000 - Added Questions 15, 16, 17, & 18
    10/3/2000 - Added reference to .msi file added in September release
    10/3/2000 - Added some comment on September Beta compliance
    7/28/2000 - Added helpful hints about installing thanks to Kit Lueder
    7/27/2000 - Fixed hyperlink bug in TOC Q5
    7/26/2000 - Added more information about XSL namespace
    7/19/2000 - Updated msxml2.dll to point to more current msxml3.dll
    7/19/2000 - Linked to information about MSXML from WSH
    7/16/2000 - Added information about XSD/XDR
    7/16/2000 - Added information about XSL to XSLT conversion
    7/16/2000 - Removed references to "ProgID" to avoid confusion
    7/15/2000 - Fixed page title, spelling error in "regsvr32"
    7/13/2000 - First posted to web


       收藏   分享  
    顶(0)
      




    ----------------------------------------------

    -----------------------------------------------

    第十二章第一节《用ROR创建面向资源的服务》
    第十二章第二节《用Restlet创建面向资源的服务》
    第三章《REST式服务有什么不同》
    InfoQ SOA首席编辑胡键评《RESTful Web Services中文版》
    [InfoQ文章]解答有关REST的十点疑惑

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/1/29 17:15:00
     
     znyan 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:0
      积分:74
      门派:XML.ORG.CN
      注册:2004/11/24

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给znyan发送一个短消息 把znyan加入好友 查看znyan的个人资料 搜索znyan在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看znyan的博客2
    发贴心情 
    ??
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/12/9 17:06:00
     
     孤独 帅哥哟,离线,有人找我吗?
      
      
      威望:7
      等级:大三(面向对象是个好东东!)(版主)
      文章:826
      积分:4220
      门派:XML.ORG.CN
      注册:2004/1/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给孤独发送一个短消息 把孤独加入好友 查看孤独的个人资料 搜索孤独在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看孤独的博客3
    发贴心情 
    admin翻下吧,^_^..

    ----------------------------------------------
    <?xml version="1.0" encoding="gb2312"?>
    <个人签名>
      <Website>[url=http://www.mahaobo.cn]
    MaHaobo.cn[/url]
    </Website>
    <Email>aloning(at)gmail.com</Email>
      <Qq >32113739</Qq>
    </个人签名>

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/18 10:45:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/6/23 20:11:17

    本主题贴数3,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    7,570.313ms