Flylib.com

Books Software

 
 
 

SOLVING XPATH PROBLEMS

 <  Day Day Up  >  

JScript

JScript is Microsoft's offering of ECMAScript (still widely referred to as JavaScript by some). InfoPath uses JScript version 5.6 or later, which corresponds to the Internet Explorer 6 rendering engine used in InfoPath. InfoPath does not use JScript.NET.

SOLVING XPATH PROBLEMS

It can sometimes be difficult to work out the correct XPath location path to access a desired node in your JScript or VBScript code. See the section titled "Using An Expression Box to Compose XPath Expressions," in Chapter 5, "Expression Boxes," for details on how to use an expression box to help you write correct XPath location paths.


Many examples of how to use JScript are included in the InfoPath Software Development Kit (SDK).

 <  Day Day Up  >  
 <  Day Day Up  >  

VBScript

VBScript, sometimes called Visual Basic Scripting Edition, is a proprietary Microsoft scripting language. InfoPath uses VBScript version 5.6 or later, which corresponds to the Internet Explorer 6 rendering engine used in InfoPath.

VBScript has many of the features of Visual Basic for Applications (VBA), but it is a weakly typed language with all objects being of type variant .

 <  Day Day Up  >  
 <  Day Day Up  >  

MSXML 5.0

Office 2003, and therefore InfoPath 2003, uses a new version of MSXML ”MSXML 5.0 (also called XML Core Services). MSXML 5.0 is an XML processor that also exposes the structure of an XML document for programmatic manipulation. MSXML includes an implementation of the W3C XML Document Object Model (with some proprietary Microsoft extensions).

MSXML is no ordinary XML processor, a term that in many implementations refers simply to an XML parser. MSXML is an extensive implementation of several XML technologies, including XPath, DOM, SAX (Simple API for XML), XSLT, and W3C XML Schema (see Figure 17.20). Because MSXML and each of these technologies could merit a book on their own, the description given here is necessarily brief.

Figure 17.20. Help is available with each of the many XML technologies in MSXML 5.0.

graphics/17fig20.jpg

When using MSXML 5.0 in InfoPath, the most relevent aspects are the DOM implementation and XPath implementation.

 <  Day Day Up  >  
 <  Day Day Up  >  

The XML DOM in InfoPath

The XML Document Object Model (DOM) models the XML that forms the data source of an InfoPath form template. As the user adds, deletes, or modifies data in a form control, the InfoPath client automatically makes the corresponding modifications to the DOM behind the scenes. When the user elects to save a form, the data contained in the modified in-memory DOM is saved to disk.

The DOM and XPath

The XML DOM has many similarities to the XPath 1.0 data model. Both models represent an XML document as a hierarchy of nodes. In the DOM, an XML document is represented as a Document node. In InfoPath, the main node types that you will spend time with, other than Document , are Element and Attribute .

MSXML allows you to access nodes in the DOM using XPath expressions.

SHOP TALK
SAVE YOUR WORK OFTEN

The Microsoft Script Editor is a powerful scripting environment, but it can also be a frustrating tool.

In the release version of InfoPath 2003, the Microsoft Script Editor sometimes (although infrequently) hangs completely with no obvious cause. You can get into a situation in which the Script Editor won't allow you to edit or exit. The only thing you can do is close down InfoPath, and you'll lose all the unsaved design work on all open form templates along with all your scripting code. To avoid frustration, be sure to save design work and script code often. This hasn't happened to me often, but it's very annoying to lose your work.

Another quirk of the Script Editor occurs when you have multiple windows open ”for example, several InfoPath windows , task panes, the InfoPath Help window, and the Microsoft Script Editor and its Help window. Windows XP varies in whether it displays the Help window in the taskbar. When you click on the icon on the taskbar you want to open, the Script Editor sometimes takes you to the Script Editor Help window. If this happens, clicking on the Minimize button in the Script Editor Help window will hide it and allow you to edit your script in the main Script Editor window.


 <  Day Day Up  >