Stylus Studio User Guide
Stylus Studio User Guide
General Information
Copyright
How to Use This Help System
Tool bar
Navigation pane
Topic pane
Search Tips
AND, OR, NEAR, and NOT (Boolean) Operators
Nested Expressions
Search Tab Options
Other Helpful Tips
Wildcards
Case Sensitivity
Sorting Topics
Searching for a Phrase
Java and COM
Conventions in This Document
Typographical Conventions
Syntax Notation
Information Alerts
Edition Alerts
Video Alerts
Technical Support
iii
Contents
iv
Contents
Modifying Values
Moving Around the Grid
Working with Stylesheets Getting Started
Opening a Sample Stylesheet
XSLT Stylesheet Editor Quick Tour
Parts of the XSLT Editor
Exploring the XSLT Source Tab
Exploring the Params/Other Tab
XSLT Scenarios
Working with Scenarios
About Preview
Working with a Sample Result Document
Using the XSLT Mapper Getting Started
Opening the XSLT Mapper
Mapping Nodes in Sample Files
Saving the Stylesheet and Previewing the Result
Deleting Links in Sample Files
Defining Additional Processing in Sample Files
Debugging Stylesheets Getting Started
Setting Up Stylus Studio to Debug Sample Files
Inserting a Breakpoint in the Sample Stylesheet
Gathering Debug Information About the Sample Files
The Variables Window
The Call Stack Window
The Watch Window
Ending Processing During a Debug Session
Defining a DTD Getting Started
Process Overview
Creating a Sample DTD
Defining Data Elements in a Sample DTD
Defining the Container Element in a Sample DTD
Defining Structure Rules in a Sample DTD
Examining the Tree of a Sample DTD
Defining an XML Schema Using the Diagram Tab Getting Started
Introduction to the XML Schema Editor Diagram Tab
Diagram Pane
Text Pane
Definition Browser
Editing Tools of the XML Schema Diagram Tab
Contents
vi
Contents
vii
Contents
Contents
Bookmarks
Search/Replace
Use of Colors in the Text Tab
How to Change Colors
Using the Spell Checker
Default Spell Checking
Manual Spell Checking
Specifying Spell Checker Settings
How to Spell Check a Document
Using the Personal Dictionary
Moving Around in XML Documents
Line Numbers
Bookmarks
Tags
Find
Updating DOM Tree Structures
Displaying All Nodes in the Tree View
Adding a Node in the Tree View
Deleting a Node in the Tree View
Moving a Node in the Tree View
Changing the Name or Value of a Node in the Tree View
Obtaining the XPath for a Node
Using the Grid Tab
Layout of the Grid Tab
Features of the Grid Tab
Expanding and Collapsing Nodes
Collapsing Empty Nodes
Renaming Nodes
Resizing Columns
Showing Row Tag Names
Moving Around the Grid Tab
Selecting Items in the Grid
How Grid Changes Affect the XML Document
Types of Changes that Affect the Document
Working with Rows
Reordering Rows
Adding and Deleting Rows
Working with Columns
Selecting a Column
ix
Contents
Adding Columns
Deleting Columns
Reordering Columns
Renaming Columns
Changing a Value
Working with Tables
Adding a Nested Table
Moving a Nested Table
Deleting a Table
Sorting a Table
Copying a Table as Tab-Delimited Text
Diffing Folders and XML Documents
Overview
Sources and Targets
The Diff Configuration File
What Diffs Are Calculated?
Tuning the Diffing Algorithm
When Does the Diff Run?
Running the Diff Manually
Symbols and Background Colors
Diffing Folders
Features
How to Diff Folders
How to Diff Documents from the Diff Folders Dialog Box
The XML Diff Viewer
Split View - Tree
Split View - Text
Merged View
View Symbols and Colors
The XML Diff Viewer Tool Bar
Tools for Working with Documents
Removing a Target Document
Diffing a Pair of XML Documents
How to Diff a Pair of Documents
Diffing Multiple Documents
Document Focus
Symbols Used in the Target Document Window
How to Diff Multiple Documents
Modifying Default Diff Settings
Contents
xi
Contents
xii
Contents
xiii
Contents
Contents
xv
Contents
Contents
xvii
Contents
xviii
Contents
xix
Contents
Example
xsl:choose
Format
Description
xsl:comment
Format
Description
Example
xsl:copy
Format
Description
Example
xsl:copy-of
Format
Description
xsl:decimal-format
Format
Description
xsl:element
Format
Description
Example
xsl:fallback
xsl:for-each
Format
Description
Example
xsl:for-each-group
Format
Description
xsl:function
Format
Description
Example
xsl:if
Format
Description
Example
xsl:import
xx
Contents
Format
Description
xsl:import-schema
Format
Description
Example
xsl:include
Format
Description
xsl:key
Format
Description
xsl:message
Format
Description
xsl:namespace-alias
Format
Description
xsl:number
Format
Description
Example
xsl:otherwise
xsl:output
Format
Description
xsl:output-character
Format
Description
Example
xsl:param
Format
Description
Passing parameters to templates
xsl:preserve-space
xsl:processing-instruction
Format
Description
Example
xxi
Contents
xsl:sequence
Format
Description
Example
xsl:sort
Format
Description
Example
xsl:strip-space
xsl:stylesheet
Format
Description
xsl:template
Format
Description
xsl:text
Format
Description
Examples
xsl:transform
xsl:value-of
Format
Description
Example
xsl:variable
Format
Description
xsl:when
xsl:with-param
Format
Description
Example
Contents
xxiii
Contents
Contents
xxv
Contents
xxvi
Contents
xxvii
Contents
Contents
Creating DTDs
About Editing DTDs
Restrictions
About Modifiers in Element Definitions in DTDs
Description of Element Modifiers in DTDs
Simple Example of Aggregating Modifiers in DTDs
More Complex Example of Aggregating Modifiers in DTDs
Aggregating Modifiers to Allow Any Order and Any Number in DTDs
Defining Elements in DTDs
Defining Elements in the DTD Tree Tab
Specifying That an Element Can Have an Attribute in DTDs
Specifying That an Element is Required in DTDs
Specifying That an Element is Optional in DTDs
Specifying That Multiple Instances of An Element Are Allowed in DTDs
Specifying That An Element Can Contain One of a Group of Elements in DTDs
Specifying That an Element Can Contain One or More Elements in DTDs
Specifying That an Element Can Contain Data in DTDs
Moving, Renaming, and Deleting Elements in DTDs
Defining General Entities and Parameter Entities in DTDs
Steps for Defining Entities in DTDs
General Entity Example in a DTD
Parameter Entity Example in a DTD
Inserting White Space in DTDs
Adding Comments to DTDs
About Node Properties in DTDs
Description of Element Properties in DTDs
Description of Attribute Properties in DTDs
Description of Entity and Parameter Entity Properties in DTDs
Associating an XML Document with an External DTD
Moving an Internal DTD to an External File
xxix
Contents
xxx
Contents
xxxi
Contents
xxxii
Contents
xxxiii
Contents
Contents
O is for Order By
R is for Return
Other Parts of the XQuery FLWOR Expression
Declaring XQuery Types
XQuery Position Variables
Multiple Assignments
Grouping
Building an XQuery Using the Mapper
Process Overview
Working with Existing XQuery
Saving the Mapping
Data Sources
Choosing a Data Source
Source Documents and XML Instances
Source icons
How to Add a Source Document
How to Change a Source Document Association
How to Remove a Source Document
How Source Documents are Displayed
Document structure symbols
Getting source document details
Specifying a Target Structure
Using an Existing Document
Building a Target Structure
Modifying the Target Structure
Adding a Node
Removing a Node
Setting a Text Value
Mapping Source and Target Document Nodes
Preserving Mapper Layout
Left and Right Mouse Buttons Explained
How to Map Nodes
Link Lines Explained
Removing Source-Target Map
Simplifying the Mapper Canvas Display
Other Mapper Display Features
Exporting Mappings
Searching Document Panes
FLWOR Blocks
xxxv
Contents
xxxvi
Contents
xxxvii
Contents
xxxviii
Contents
xxxix
Contents
Contents
xli
Contents
Contents
Identifying Resources
Deployment Considerations
Use Case: Building order.pipeline
order.pipeline Requirements
Getting Started: Creating a New XML Pipeline
Save the XML Pipeline
XML Pipeline Scenarios
Specifying an Execution Framework
When to Specify the Execution Framework
Configuring Data Sources
Ways to Configure Non-XML Data Sources
Convert booksXML.txt Using a Built-in XML Converter
Create a ConvertToXML Node for booksXML.txt
Create a ConvertToXML Node for order.edi
Renaming Nodes
The XML Pipeline So Far
Using XQuery to Merge Source File Data
Using Variables to Reference Data Sources
Looking at the XQuery Code
Adding an XQuery Node
Changes to Source Documents
Setting the XQuery Node Data Sources
Default and Specified Port Values
An Alternate Way to Create ConvertToXML Nodes
Testing the XML Pipeline
Setting a Value for an Output Port
Designing a Report from the XML Document
Adding XSLT and XQuery Transformations
Add createReport.xsl
Add createReport.xquery
Finishing Up
Working with Nodes
Types of Nodes
Adding Nodes to an XML Pipeline
Using Existing Documents
Using the Toolbox
Node and Port Names
XQuery and XSLT Nodes
Input Ports
xliii
Contents
Output Ports
Scenario Properties
Changes to Source Code
Managing Processor Conflicts
XSL-FO Nodes
Input Port
Output Ports
Pipeline and Related Nodes
Example
Pipeline Node Input and Output Ports
How to Include an XML Pipeline
Validate Nodes
Using Multiple XML Schemas
Input Port
Output Ports
Choose Nodes
Input Ports
Adding Input Ports
Output Ports
Adding Output Ports
ConvertToXML and ConvertFromXML Nodes
Specifying an XML Converter URL
Creating a ConvertToXML Node
Input Port
Output Ports
For More Information
Stop and Warning Nodes
Stop Nodes
Warning Nodes
XML Parser Nodes
Input Port
Output Ports
XML Serializer Nodes
Input Port
Output Ports
Working with the XML Pipeline Diagram
Displaying a Grid
Labeling
Zoom
xliv
Contents
Edge Style
Manipulating Nodes in the Diagram
Saving the XML Pipeline Diagram as an Image
Labeling XML Pipeline Diagrams
Debugging an XML Pipeline
Cross-Language Debugging
Execution Framework Determines Debugging Support
Setting and Removing Breakpoints
Running the Debugger
Stepping Into a Node
Stopping Debug Processing
Generating Code for an XML Pipeline
Execution Framework and Code Generation
Processors for which Code Generation is Supported
XML Pipeline Node Restrictions for C# Code
Code Generation Settings
Java Code Generation Settings
C# Code Generation Settings
How to Generate Code for an XML Pipeline
Compiling Generated Java Code
How to Compile and Run Java Code in Stylus Studio
Troubleshooting Compiling Inside Stylus Studio
Compiling Java Code Outside Stylus Studio
Running Java Code in Stylus Studio
Deploying Generated Code
XML Pipeline Node Properties Reference
Choose Node Properties
Input Port
Node
Output Port
ConvertFromXML Node Properties
Input Port
Node
Output Port
ConvertToXML Node Properties
Input Port
Node
Output Port
Pipeline Node Properties
xlv
Contents
Input Port
Node
Output Port
Pipeline Input Node Properties
Node
Output Port
Pipeline Output Node Properties
Input Port
Node
Stop Node Properties
Input Port
Node
Validate Node Properties
Input Port
Node
Output Port
Warning Node Properties
Input Port
Node
Output Port
XML Parser Node Properties
Input Port
Node
Output Port
XML Serializer Node Properties
Input Port
Node
Output Port
XQuery Node Properties
Input Port
Node
Output Port
XSL-FO Node Properties
Input Port
Node
Output Port
XSLT Node Properties
Input Port
Node
xlvi
Contents
Output Port
xlvii
Contents
Lists
Creating a List
Graphical Representation
Sorting
Adding Items
Deleting an Item or a List
Text
Creating a Text Component
Graphical Representation
Images
Creating an Image
Graphical Representation
Specifying an Image Source
Specifying Image Size
Repeaters
Creating a Repeater
Graphical Representation
Sorting
Ifs
Creating an If
Graphical Representation
Example
Component Properties
Context and XPath Sub-Properties
The Properties Window
Example: Using Context and XPath Sub-Properties to Format Text
Entering XPath Expressions
Formatting Components
Formatting Numbers
Styles
Ways to Apply Styles
Formatting Influenced by Component Hierarchy
Setting Default Properties
Clearing Formats
Formatting Decimal Numbers
Where You Specify Decimal Number Formats
Where You Specify Picture Strings
Example
Generating Code for an XML Publisher Report
xlviii
Contents
xlix
Contents
Contents
Choose Server
Choose Source and Destination Schema
Choose the WSDL Operation
Class Properties
Code Definition
Code List Definition
Composite Definition
Configure External XQuery Processor
Connection Settings
Convert DTD to XML Schema
Convert HTML to XML
Convert HTML to XSLT
Convert XML to XML Schema
Create Java Console
Create Java Servlet
Create Relationship
Create Schema or DTD
Create User-Defined Catalog
Create XML Document from DTD
Create XML Document from XML Schema
Custom Document Wizard Arguments
Custom XML Conversion Editor
Customize Toolbars
DataDirect XQuery Options
Default Value
Description
Diagram Properties Schema Details
Diagram Properties WSDL Details
Diff Folders
Document Wizards
DTD Schema Editor Text Tab
DTD Schema Editor Tree Tab
DTD to XML Schema (Trang)
EDI Document Pane
EDI Structure Tree
EDI to XML Editor
Element Definition
Find
Find (Mapper)
li
Contents
File Explorer
Generate C# .NET Code for XML Pipeline
Generate Java Code for XML Pipeline
Generate Transformation
Generate XML Schema from EDI Standards
Generate XQuery from EDI Standards
Generate XQuery/XML Schema
Go To (Custom XML Conversion)
Go To
Group Definition
Illegal Character Found
Import File
Imported Files
Imported Modules
Java Class Browser
Java Code Generation
Java Editor
Java Method Browser
Keyboard Accelerators
Lookup List
Message Definition
Name
Named Template
Named/Matched Template
New Custom XML Conversion Definition
New EDI to XML Conversion
New Function
Notes
Open and Save As
Options
Options - Application Settings
Options General Back-mapping
Options General Components XML Converters for Java
Options General Components XML Converters for .NET
Options General Components DataDirect XQuery
Options - General - Custom Document Wizards
Options - General - Custom Tools
Options - General - Custom Validation Engines
Options - General - Editor Format
lii
Contents
liii
Contents
liv
Contents
lv
Contents
lvi
General Information
This topic provides the following information:
Copyright
2011 DataDirect Technologies Corp. All rights reserved. Printed in the U.S.A.
DataDirect, DataDirect Connect, DataDirect Connect64, DataDirect Spy, DataDirect
Test, DataDirect XML Converters, DataDirect XQuery, SequeLink, Stylus Studio, and
SupportLink are trademarks or registered trademarks of Progress Software Corporation
or one of its subsidiaries or affiliates in the United States and other countries. Java and all
Java-based trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc. in the United States and other countries. MySQL and MySQL
Enterprise are registered trademarks of MySQL AB in the United States, the European
Union and other countries.
Other company or product names mentioned herein may be trademarks or registered
trademarks of their respective companies.
DataDirect products for the Microsoft SQL Server database:
These products contain a licensed implementation of the Microsoft TDS Protocol.
DataDirect Connect for ODBC includes:
lvii
lviii
Tool bar
The Tool bar provides the following buttons:
Locate Opens the Contents tab, and highlights the current topic to indicate where
it is located.
Forward Returns you to the topic you were viewing before you clicked Back.
Print If you are in the Contents tab, provides options to print the selected topic or
the selected heading and all its subtopics. If you are in the Index or Search tab, it
opens the Print dialog box to print the current topic.
lix
Options Opens a menu that contains all of the commands found on the Toolbar,
providing accessibility shortcut keys for each. The following commands are also
provided:
Stop Stops downloading file information. Use this feature when the Help
system contains a link to the Web; you can choose this option to stop a Web page
from downloading.
Refresh Updates the current topic in the Topic pane. Use this feature when the
Help system contains a link to the Web.
Navigation pane
The Navigation pane displays four tabs:
Contents Click the plus (+) or minus (-) sign to the left of the topic titles to expand
or contract the table of contents.
Index Type the word or phrase you want to find into the box at the top, or use the
scroll bar to the right to scroll up and down.
Search Use advanced full-text search to search the Help system using Boolean,
wildcard, and nested expressions. See Search Tips on page lxiii for more
information.
Favorites Create a list of your favorite Help topics. To add a topic to the Favorites
tab, navigate to the topic you want and click Add.
Topic pane
The Topic pane displays the Help topics.
Click the Previous
and Next
icons, which are located at the top and bottom of
this pane, to navigate to the topics that immediately precede and follow the topic that you
are viewing.
Search Tips
Advanced full-text search allows you to search the entire Help system.
lx
Search Tips
Searches For
Example
Returns
AND
OR
cat OR feline
NEAR
NOT
AND narrows a search by returning only topics containing all of the words you search
for. The more words you join together with AND, the fewer topics the search returns.
lxi
Nested Expressions
Use parentheses to group words together when you are using more than one Boolean
operator and three or more words. Expressions that are placed between parentheses are
evaluated before the rest of the search statement. This allows you to combine several
search statements into one, therefore creating more complex searches. For example, water
AND (polo OR aerobics) searches for topics containing information about both water polo
and water aerobics.
Note If a search contains multiple Boolean operators, but does not contain a nested expression,
it is evaluated from left to right. For example, water AND polo OR aerobics (without
parentheses) is the same as (water AND polo) OR aerobics, and finds topics containing
information about water polo or aerobics, but not water aerobics.
checked and unchecked when you select the Search tab for a new search.
Choose this option to search only the results of a previous search. This lets you narrow
a search that resulted in too many topics the first time. If you want to search all topics
of the Help system, you must make sure this option is unchecked.
Choose this option to find any close match to the word you are searching for. This lets
you match similar spellings and minor grammatical variations. For example, if you
search for jump, choosing this option will find jump, jumps, and jumped.
lxii
Search Tips
Choose this option to search among topic titles only, rather than for every instance of
the word. This narrows your search to topics that might be the most pertinent.
Wildcards
Use the asterisk (*) in a search to represent one or more letters. For example, searching
for h*t returns a list of topics that contain pat, pet, pit, pot, and put, while searching for
dat* returns a list of topics containing date, data, dateline, and database.
Case Sensitivity
Searches are case insensitive. You can type the word you want to search for in uppercase
or lowercase letters, or in a combination of the two, without affecting the results.
Sorting Topics
One search returns up to 500 topics. You can sort the list of topics in ascending order,
alphabetically by title or numerically by rank. To sort the list, click the Title or Rank
column heading.
Note Since the Location column contains no distinguishing information, you can omit it from
lxiii
for in quotation marks. Otherwise, the periods and colons are treated by the search as OR
operators.
Typographical Conventions
This document uses the following typographical conventions:
Bold typeface in this font indicates keyboard key names (such as Tab or Enter) and
the names of windows, menu commands, buttons, and other user-interface elements.
For example, From the File menu, select Open.
Italic typeface in this font emphasizes new terms when they are introduced.
Monospace typeface indicates text that might appear on a computer screen other than
the names of user-interface elements, including all of the following:
lxiv
Syntax Notation
This document uses the following syntax notation conventions:
Braces ({ }) indicate that one (and only one) of the enclosed items is required. A
vertical bar (|) separates the alternative selections.
Ellipses (...) indicate that you can choose one or more of the preceding items.
Information Alerts
This document highlights special kinds of information by shading the information area,
and indicating the type of alert in the left margin.
Tip A Tip flag indicates helpful usage information about Stylus Studio.
Note A Note flag indicates information that complements the main text flow. Such information
ignored.
Edition Alerts
Some features are supported only in certain Stylus Studio XML editions. Documentation
that describes these features is identified with an alert like the following:
:
XML Pipeline support is available only in Stylus Studio XML Enterprise Suite
.
A summary of features by edition can be found in Stylus Studio Editions on page 3.
lxv
Video Alerts
Stylus Studio provides many video demonstrations of its features. Documentation that
describes a feature for which a video demonstration exists is preceded by an alert like the
following:
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the XQuery
Mapper video.
You can learn more about other video demonstrations here:
http://www.stylusstudio.com/xml_videos.html (or select Products > XML Video
Demonstrations from the Stylus Studio Web site menu.
Technical Support
Submit questions and report problems using the Stylus Studio Developer Network
(SSDN). SSDN has numerous active forums, including specialized forums for
XQuery
XSLT
Feature requests
SSDN is fully searchable, and contains current as well as historical information about
Stylus Studio and XML technologies. If you cannot find the answer to the question you
have, submit it to the forum and a Stylus Studio technician will respond to you.
When submitting a question or reporting an issue, it often helps to state the version of
Stylus Studio you are running (click Help > About Stylus Studio on the menu bar) as well
as any other information about your environment you think might be relevant (such as the
JVM version you are using, for example).
lxvi
Chapter 1
Stylus Studio is an integrated development environment (IDE) for XML and related
technologies. Stylus Studio allows you to design, develop, and test XML applications
using its intuitive graphical interface, textual editors, and debuggers for XML, XML
Schema, DTD, XQuery, XSLT, Web services, and Java.
XML
XQuery
XSLT
XML Pipelines
XML reporting
DTD
XML Schema
Web services
Java
Defining an XML Schema Using the Diagram Tab Getting Started on page 66
Java and C# for .NET code generation for deployment of XQuery and XSLT
transformations
XQuery and XSLT Profilers to help you gather performance metrics and troubleshoot
performance bottlenecks
Custom XML Conversions, a module that allows you to easily convert non-XML files
like EDI and CSV to XML
Web Service Call Composer to help you build and test calls to hundreds of industrystandard Web services
Support for OASIS catalogs, including dozens of catalogs bundled with Stylus Studio
Edition Alerts
The Stylus Studio User Guide describes features found in all Stylus Studio editions.
Alerts, like the one shown here, are used to identify documentation describing features
found only in particular Stylus Studio editions.
The XML Editor Grid tab is available only in Stylus Studio XML Enterprise Suite
and Stylus Studio XML Professional Suite.
More Information
For a complete description of Stylus Studio XML Enterprise Suite, Stylus Studio XML
Professional Suite, and Stylus Studio Home Edition, see the Stylus Studio Web site:
http://www.StylusStudio.com/xml_feature_comparison.html
Integrated Components
Stylus Studio XML Enterprise Suite is fully integrated with these DataDirect products:
DataDirect XQuery
The XML Converters are high-performance Java and .NET components that provide
bi-directional, programmatic access to virtually any non-XML file including EDI, flat
files, and other legacy formats. DataDirect XML Converters allow developers to
seamlessly stream any non-XML data as XML to industry-leading XML processing
components or to any application. They support StAX, SAX, XmlReader, XmlWriter,
DOM and I/O streaming interfaces, and can be embedded directly for transformation
purposes, or as part of a chain of programs including XSLT and XQuery, or even inside
XML pipelines. DataDirect XML Converters maximize developer productivity and
Integrated Components
provide a fast, scalable solution for converting between EDI and other legacy formats and
XML.
DataDirect XQuery is an XQuery processor that enables developers to access and query
XML, relational data, SOAP messages, EDI, legacy, or a combination of data sources,
and, in addition, provides full update support for relational data. DataDirect XQuery
supports the XQuery for Java (XQJ) API, and is easily embedded into any Java program
it does not require any other product or application server, and has no server of its own.
Evaluation copies of these DataDirect products are installed in the \Components directory
where you installed Stylus Studio. These copies provide full development libraries,
sample code, and user documentation.
The License Manager is on the Components page of the Options dialog box (click Tools
> Options on the Stylus Studio menu). As seen in the following illustration, licenses for
each component are managed separately:
The component name Folder field displays the location of the DataDirect component
installation whose license you wish to manage. You can use the License Manager to
manage license keys for
The copies of the DataDirect components that are installed with Stylus Studio. This
is the default.
1.
Select the component whose evaluation you wish to extend from the Components
tree in the Options dialog box.
2.
If necessary, change the URI in the component name Folder field to point to the folder
where the component whose license you wish to manage is installed.
Integrated Components
3.
4.
5.
6.
Select the component for which you wish to add a license from the Components tree
in the Options dialog box.
2.
If necessary, change the URI in the component name Folder field to point to the folder
where the component whose license you wish to add is installed.
3.
4.
5.
6.
Select the component whose license you wish to remove from the Components tree
in the Options dialog box.
2.
If necessary, change the URI in the component name Folder field to point to the folder
where the component whose license you wish to remove is installed.
3.
Select the license you want to remove from the License Manager list box.
4.
6.
The path shown here assumes that you accepted the defaults when you installed Stylus
Studio. If you did not, you must alter your selection path accordingly.
You can also start Stylus Studio by double-clicking the desktop icon, which is added to
your desktop by default when you install Stylus Studio:
On startup, Stylus Studio displays the Tip of the Day dialog box.
Getting Updates
By default, Stylus Studio checks the Stylus Studio Web site for newer versions each time
you start the application. You can review and modify this and other application settings
by selecting Tools > Options from the menu bar and selecting the Application Settings
page.
If you want, you can perform this check manually by selecting Help > Check for latest
version from the Stylus Studio menu.
Getting Help
As you use Stylus Studio, you can press F1 at any time to obtain context-sensitive help.
If you want, you can open the online help manually (and independent of the Stylus Studio
application) by selecting Start > Programs > Stylus Studio XML Edition Name> Stylus
Studio Documentation.
Note The online documentation is not installed with Stylus Studio. The first time you access
the online documentation, you are prompted to download it from the Stylus Studio web
site. By default, the online documentation is installed in the \doc directory where you
installed Stylus Studio.
In the File Explorer window, navigate to the examples\quotes directory in your Stylus
Studio installation directory.
10
Double-click your-quotes.xml.
Stylus Studio displays the your-quotes.xml document in the XML editor. The initial
view of the document is the Text view, as you can see by the tab at the bottom of the
window.
text editors. Orange, for example, identifies elements that are not associated with a
schema. You can change the colors for editors individually. Select Tools > Options from
the menu bar, then select Editor Format. You select the editor whose settings you want to
modify using the Editor drop-down list.
Alternatives
The File Explorer window is the primary way to open and access files in Stylus Studio,
but you can also open files using:
The Open dialog box, which is displayed when you select File > Open from the menu
bar or click the Open
button on the tool bar, for example.
The Project window, which is displayed on the left of the Stylus Studio desktop. The
Project window shows only those files associated with Stylus Studio projects.
Stylus Studio User Guide
11
12
Figure 6. Sense:X and Other Editor Features are in the Options Dialog Box
3.
4.
5.
Click OK.
In the XML editor window, click in the first line just after <ticker>.
2.
Sense:X Auto-Completion
As soon as you type the closing forward slash, Stylus Studio displays company> because
it is the only element that is appropriate to close. Automatic closing of open tags is part
of Stylus Studios Sense:X intelligent editing. You can change this and other Sense:X
options on the Editor General page of the Options dialog box for example, you can have
Stylus Studio display a list of appropriate elements, even if that list includes one only
item.
13
Stylus Studios Sense:X provides even greater functionality if the document you are
editing has either a DTD or XML Schema associated with it. See Sense:X Speeds
Editing on page 145 for more information.
Use the mouse to select the text for one quote element and its contents.
2.
3.
Scroll down in the XML editor and click just before </ticker>.
4.
14
1.
In the menu bar, select Edit > Undo to remove the text you just pasted.
Alternative: Press Ctrl+Z.
2.
In the menu bar, select Edit > Redo to replace the text you just removed.
Alternative: Press Ctrl+Y.
3.
Stylus Studio displays a message that alerts you that there is an open tag for a quote
element but no close tag. The messages indicates the line and column in which the
error was found.
4.
In the alert box, click OK. Because the document is not well-formed XML, Stylus
Studio does not insert indents in the document. The next topic, Inserting Indents in
the Text View of a Sample Document on page 16, shows how to fix the document so
that it is well-formed.
15
2.
Tip
In line 2, click after the </company> tag and type </. By default, Stylus Studio displays
quote> because it is the only element that is appropriate to close.
4.
Indent XML Tags changes your XML document by inserting white space. If this is
undesirable, and you want to check for well-formedness, click the Tree tab at the bottom
16
of the XML Editor window. If the document is well-formed, Stylus Studio displays the
tree representation. If the document is not well formed, Stylus Studio displays a message
that indicates the reason the document is not well formed and the location of the error or
omission.
).
This topic is part of a sequence. If your-quotes.xml is not open, see Opening a Sample
XML Document on page 10. The sequence starts with Adding Elements in the Text
View of a Sample Document on page 13.
To query your-quotes.xml:
1.
17
18
2.
3.
In the Query Output window, expand the second quote element to view its contents.
In the Text view, click the down arrow to the right of the query field.
6.
In the XPath Query Editor window, click the New Query button (
Stylus Studio adds a new tab for each query you define.
7.
8.
Close the XPath Query Editor window by clicking the x in that windows upper right
corner.
).
19
you must open it in the DTD editor. When an XML document has an internal DTD, you
can view and edit it in both the Schema tab and the Text tab of the XML editor.
You should have already performed the steps in Updating the Text of a Sample
Document on page 12. Each of the following topics contains instructions for editing the
sample XML document. You should perform the steps in each topic before you move on
to the next topic. After the first topic, some steps depend on actions you performed in a
previous topic.
This section includes the following topics:
20
1.
2.
At the bottom of the XML editor window, click the Schema tab.
Stylus Studio displays the Schema tab, and opens the Properties window. The
Schema tab displays a DTD tree, which is currently empty.
To create a schema for your-quotes.xml, select XML > Create Schema from XML
Content from the Stylus Studio menu.
Stylus Studio displays the Create Schema or DTD dialog box. By default, Stylus
Studio generates an internal DTD and inserts it in a DOCTYPE element at the beginning
of the document. You can also use this dialog box to generate an external XML
Schema or DTD.
21
Click Yes to instruct Stylus Studio to create a DTD based on the XML document
content.
Stylus Studio displays a tree representation of the new, internal DTD. It also displays
the Properties window.
22
This selects the company element definition and displays the properties for the company
element in the Properties window.
The Content Model property indicates the allowable contents for a company element.
In this example, it is Mixed, which means that a company element can contain specified
elements (as opposed to all elements defined in this DTD), attributes, and raw data.
Windows like the Properties and Query Output windows are docking windows you
can change their location within the Stylus Studio window, or separate them from the
Stylus Studio entirely, by dragging them to the desired location.
Tip
2.
3.
Type location and press Enter. Stylus Studio displays the properties for the new
location element in the Properties window.
23
In the left tool bar, click New Modifier . Stylus Studio displays a drop-down menu
of options that specify the rules for the occurrence of the children of the new element.
Double-click Zero or More (or click once to select it and press Enter).
7.
24
1.
2.
3.
4.
5.
6.
7.
To move the location element to be earlier in the sequence, click its Optional
modifier.
2.
3.
Type TCBCC for the name of the entity and press Enter.
In the Properties window, Stylus Studio displays the properties for the new entity.
4.
5.
Type The
press Enter.
25
Adding Attributes and Other Node Types to a Sample Document Tree on page 28
26
2.
At the bottom of the XML Editor window, click the Tree tab.
Stylus Studio closes the Properties window.
You can close the Output window if it is still open from the previous exercise.
Tip
3.
Click the plus sign next to the ticker element to expose the children of the ticker
element.
4.
5.
6.
2.
3.
4.
5.
27
Click Change Value. Stylus Studio activates the value field for the exchange element.
7.
2.
28
3.
4.
In the attribute value field, type Star Brokers and press Enter.
Stylus Studio displays an entry field for a new attribute name, allowing you to easily
add a number of attributes, one after the other.
5.
6.
8.
9.
If it is not already selected, click the quote element you defined in the previous topic.
2.
3.
4.
5.
6.
Double-click TCBCC.
Stylus Studio inserts the text The
the company element.
7.
Click the Text tab at the bottom of the XML editor window.
Stylus Studio displays the &TBCC; entity reference in the new company element.
29
2.
At the bottom of the XML Editor window, click the Grid tab.
Stylus Studio displays a table that contains the XML data.
The left most column, with the Tag Name heading, contains the children of the
<ticker> element. The remaining columns contain the grandchildren of the <ticker>
30
element. The heading of each column identifies the element name company,
symbol, and so on.
You can resize columns by dragging the handle on the column headings right side.
You can change the element order in the document by dragging the handle on the
column headings left side. Stylus Studio swaps positions with the column on which
you come to rest.
Tip
3.
Select the last row by clicking to the left of the last <quote> element.
The row is highlighted in blue.
31
6.
Press Tab (or use the right arrow key) to move the cursor to the next cell in the row.
7.
Repeat Step 5 and Step 6 to create values for the <symbol> and <exchange>
subelements.
8.
If you want, you can continue to add the data contained in a quote element.
Modifying Values
It is easy to change and delete values in grid fields:
To change the value of any field, double-click the field and type the new data. Press
Enter to save the change.
To delete the value of a field, double-click the field, select the text you want to delete,
and press the Delete key.
Use the Tab key to advance the focus to the next cell; use Shift + Tab to move the
focus to the previous cell
Use the arrow keys to move the focus in the direction of the arrow you choose
32
In the File Explorer or Open dialog box, navigate to the examples\quotes directory in
your Stylus Studio installation directory.
Alternative: If the Stylus Studio examples project is open, you can access this file from
the Project window. To open the examples project, open examples.prj in the Stylus
Studio examples directory.
33
As with the XML Editor, Stylus Studio uses different colors to distinguish markup,
tag names, and data in the XSLT Editor.
34
XSLT Source. Use the XSLT Source tab when you want to directly edit or view the
XSLT source code that comprises your stylesheet. The XSLT Source tab can also be
a good way to learn more about XSLT.
XSLT source is also visible from a pane within the Mapper tab.
Tip
Mapper. The Mapper tab allows you to create XSLT by graphically mapping source
document nodes to nodes in a target document. Stylus Studio interprets the mappings
to generate XSLT that will yield a document conforming to the document described
in the Set Target Document pane.
Using the Mapper tab is discussed in detail in Using the XSLT Mapper Getting
Started on page 44.
Note
Params/Other. You use the Params/Other tab to specify the encoding Stylus Studio
uses to store the stylesheet, the stylesheets output method, and the encoding Stylus
Studio uses for the document that results from applying this stylesheet. You can also
use this tab to view default values for parameters used by your stylesheet.
In the stylesheet text, click anywhere below the third xsl:template instruction (line
11).
35
In the status bar just below the XSLT Editor tool bar, Stylus Studio displays match: /.
This indicates that the location you clicked is inside a template that matches the root
node.
Figure 21. Current Template Identity Is Displayed at the Top of the Editor
2.
3.
To define a new template, replace NewTemplate with the match pattern you want, and
add contents to the new template as needed.
Tip
You can also create a new template by double-clicking a node on the schema tree.
Templates that match nodes in the XSLT document are displayed with a check in the
schema tree, as shown here.
Yellow indicates that the text cursor in the XSLT source is within that template.
36
You can edit the stylesheet in either template mode or in full source mode. In template
mode, Stylus Studio displays one template at a time. In full source mode, Stylus
Studio displays the whole stylesheet.
In large or complex stylesheets, use the XSLT Editors status bar to identify the
current template.
Tip
5.
In the upper right corner of the editing pane, click the down arrow.
Stylus Studio displays a list of the templates in the stylesheet with their match
patterns.
Click match: *|/. This displays the template that matches every element and the root
node.
Every stylesheet that Stylus Studio creates includes two built-in templates. One builtin template matches every element and the root node. The other built-in template
matches all text and attribute nodes. See Using Stylus Studio Default Templates on
page 437.
To delete a template, click the match pattern for the template you want to delete and
in the XSLT Editor tool bar. You must be in template
then click Delete template
mode to delete a template.
37
Drop-down menus let you specify the encoding format used to store the stylesheet in
Stylus Studio, as well as method and encoding output attributes. A simple grid displays
the name, source URL, and default value of any global parameters used by the active
stylesheet, as well as by any imported ones.
All information that you can specify in the Params/Other tab can also be specified in the
XSLT source. For example, you can specify the XSLT encoding in the processing
instruction at the beginning of the stylesheet; you can specify the output method and
encoding with the xsl:output instruction. Stylus Studio automatically updates the XSLT
source with any changes you make in the Params/Other tab, and vice versa.
XSLT Scenarios
This topic is part of a sequence. If your-quotes.xsl is not open, see Opening a Sample
Stylesheet on page 33. The sequence starts with Exploring the XSLT Source Tab on
page 35.
38
Figure 25. Scenarios Let You Easily Test Stylesheets and XML Source
You can define multiple scenarios using different settings to see how each affects
document processing. Stylus Studio also supports scenarios for Web service calls,
XQuery, and XML pipelines.
An XSLT scenario is defined by a single stylesheet-XML document pair. You can
associate any number of scenarios with a stylesheet, though only one scenario can be in
effect at the time the XSLT is processed. Similarly, you can associate any number of
scenarios with an XML source document.
Tip Stylus Studio lets you work with several XSLT processors, including Saxon, MSXML
and .NET.
A scenario has already been created for the your-quotes.xsl stylesheet, using the yourthe source XML document. Run the scenario now and look at the output
created by the XSLT defined in your-quotes.xsl.
quotes.xml as
39
Stylus Studio processes the source XML document using the XSLT stylesheet you specify
and displays the results in the Preview window.
Figure 26. XSLT Processing Results are Shown in the Preview Window
By default, results are displayed using a Web browser. If you choose, you can display
results in tree or text format, by clicking Preview in Tree
and Preview Text
in the
Preview window tool bar.
Use the scroll bar to review the HTML in the Preview window. You can see that the values
come from the XML document your-quotes.xml.
Tip If it is not already open, you can open the source XML document specified in a scenario
by clicking Open XML From Scenario
in the XSLT Editor tool bar.
40
About Preview
When you preview a result, Stylus Studio automatically saves the changes you have made
to the document. If you want to revert to the documents previous state, you can use the
undo function (Edit > Undo).
41
Using its back-mapping functionality, Stylus Studio displays the template in the
XSLT Editors status bar and flags the line that generated the line you clicked with a
blue pointer.
42
In the left tool bar of the Preview window, click Preview Text
displays the HTML file that generates the browser display.
. Stylus Studio
Note
3.
Click anywhere in the HTML display. The gray background identifies any HTML that
was generated by the same template.
This works in reverse as well. If you click a line in a template (full source mode or
template mode), Stylus Studio uses a gray background to display the HTML
generated by that template.
4.
43
To learn more about XSLT, see Working with XSLT on page 377.
To get started XSLT Editor features for stylesheets, see Working with Stylesheets
Getting Started on page 33.
To learn about the XSLT mapper in greater detail, see Creating XSLT Using the
XSLT Mapper on page 507.
To get started, you will need to start Stylus Studio if you havent already. See Starting
Stylus Studio on page 8 if you need help with this step.
44
From the Stylus Studio menu bar, select File > New > XSLT Stylesheet.
Stylus Studio displays the Scenario Properties dialog box.
2.
3.
The Project window also appears if it was open the last time Stylus Studio was
closed. You can close it.
Tip
4.
Click the Add Source Document button at the top of the mappers left pane.
Stylus Studio displays the Open dialog box.
45
6.
Double-click books.xml.
7.
Click the Set Target Document button at the top of the Mappers right pane.
Stylus Studio displays the Open dialog box.
8.
9.
Double-click catalog.xml.
Stylus Studio displays tree diagrams of these XML documents. The default XSLT
source code has not been altered at this point.
Figure 30. XSLT Mapper Tab with Source and Target Documents
46
You can display an entire tree using the asterisk key (*) on your keyboards number
pad.
Tip
Tip
In the Mapper tab, expand the tree for both books.xml and catalog.xml.
2.
3.
Press and hold the left mouse button, and drag from book to the Book repeating element
in catalog.xml.
Stylus Studio draws a line as you drag.
4.
Release the mouse button to create the link between book and Book.
Stylus Studio creates an xsl:for-each block that links the book and Book repeating
elements. (If you mouse over the block, xsl:for-each appears in a pop-up to indicate
the XSLT operation represented by the link.)
If you prefer, you can render xsl:for-each as a simple line. You might want to do this
to simplify the appearance of the mapper canvas. Select Tools > Options from the
menu, and then navigate to Module Settings > XSLT Editor > Mapper.
Also notice that the complete xsl:for-each instruction has been added to the XSLT
source, which appears in the XSLT source pane under the XSLT Mapper canvas. The
back-mapping pointer identifies the line of XSLT that was just added to stylesheet.
47
The template contains an xsl:for-each instruction that selects the book element,
which is the node you selected in Step 2. The output from this template is an empty
Book element, which is the node that was the target of the link. Stylus Studio created
the Catalog element automatically, to provide the document structure necessary to
support the Book element.
By default, Stylus Studio creates an xsl:value-of instruction when you link one
element to another; Stylus Studio creates an xsl:for-each instruction if you link two
repeating elements. You can also create other types of instructions graphically,
including xsl:if, xsl:choose, and xsl:apply-template.
Tip
5.
6.
7.
Note
48
Create another link from the title element to the Title element.
When you map, you always map from the source document to the destination
document.
Click the XSLT Source tab to see the new instructions in the template. (If you prefer,
you can simply adjust the splitter between the XSLT source pane and the XSLT
Mapper canvas.
Figure 32. Stylus Studio Builds XSLT Based on the Mapper Links
For each link you define, Stylus Studio adds instructions to the template that matches
the root node. In the XSLT you have composed so far, the XSLT inserts a Book element
for each book element it finds in the source document. In the Book element, the
stylesheet selects the title elements. For each title element, it inserts a Title
element. Finally, in each Title element, the stylesheet extracts the value of the current
context node, which is the title node.
Why does the stylesheet extract the value of the title nodes but not the book nodes?
The title node has only a text node as its child. In this situation, the default is that
the XSLT Mapper inserts an xsl:value-of instruction.
49
Click Save
2.
3.
4.
In the upper left corner of the XSLT Mapper, click Preview Result
When you create a stylesheet using the XSLT Mapper, Stylus Studio automatically
creates a scenario for you, using the source document you specify as the source
document for the scenario. Scenarios and their value in the application development
process are described earlier in this chapter. See XSLT Scenarios on page 38.
Tip
Stylus Studio displays the result of processing books.xml with the stylesheet you
created in the XSLT Mapper in the Preview window.
The result document uses the same schema as the target document, catalog.xml in
this example. Because not all nodes have been mapped yet, the result document does
not contain all nodes found in books.xml (author and subject nodes, for example).
50
5.
You can confirm that the result document is incomplete by viewing books.xml. Click
Open XML From Scenario
, which is at the top of the Mapper tab.
Stylus Studio displays the books.xml document in the Stylus Studio XML Editor.
6.
Review the XML document, and then click the document tab for the
BooksToCatalog.xsl stylesheet to re-display the XSLT Editor.
2.
Tip
b.
Go To Source displays the line of XSLT code represented by the link you select
in the XML Editor.
51
52
1.
2.
Stylus Studio applies the stylesheet and displays the results (a finished HTML page
that displays information about a single video) in the Preview window.
shown here, are dockable and can be moved anywhere you please.
53
In the XSLT Editor, click in line 202. Line numbers appear in the lower right corner
of the XSLT Editor window. Line 202 starts with
<xsl:template match="director">
To display lines in Stylus Studio text editors, click Tool > Option > Editor General,
and select Show line numbers.
Tip
2.
Do not do it, but to remove a breakpoint, you click in the line that has the breakpoint
and then click Toggle Breakpoint (or F9). The Toggle Breakpoint button and F9 key
operate as toggles.
3.
Do not do it, but to stop debugging, you can click Cancel in the lower right corner of
in the Stylus Studio tool bar.
the XSLT editor window, or click Stop Debugging
54
Figure 38. Variable, Call Stack, and Watch Windows Appear During Debugging
55
You can use the information in these windows to learn about potential and actual problems
encountered in your XSLT processing.
Tip You can also control the display of these windows using the Debug menu, shown here, or
As you can see, the stylesheet defines the VideoName parameter, which had no value when
processing was suspended. In addition, the Variables window shows you that when
processing was suspended, the processor was operating on the first director child element
of the first video child element of the first videos child element of the first result element.
56
In this example, the XSLT processor has instantiated the director template, which is part
of the instantiation of the video template, which is part of the instantiation of the template
that matches the root node.
To step out of debug Step out
, or press Shift+F11.
The processor completes the instantiation of the director template, which adds some
HTML to the Preview window. The yellow triangle moves to show the new location in the
XSLT source.
As you can see in the Call Stack window, the processor is now two levels deep in the
template that matches the root node, instead of three levels deep as it was previously. The
value of the context node in the Variables window is /result[1]/videos[1]/video[9] (it
was /result[1]/videos[1]/video[9]/director[1]).
57
2.
Type the name of the variable you want to watch and press Enter.
As processing continues, the Watch window displays the values of the variables you
specify.
58
In the lower right corner of the XSLT editor, click the Cancel button to end
processing.
Stylus Studio displays a notification message that indicates that processing has been
stopped and, optionally, allows you to jump to the location where processing ended.
59
In the XSLT editor tool bar, click Open XML from Scenario
.
Stylus Studio displays the XML source document that the stylesheet operates on. As
you can see, the first result element is the document element.
This section demonstrated some of the major features of Stylus Studios debug tools,
including specialized windows for presenting call stack and variable information. For
complete information on using the XSLT debugger, see Debugging Stylesheets on
page 551.
60
Process Overview
When you use Stylus Studio to define a DTD, the main steps you perform are:
1.
2.
3.
4.
In the container elements, specify the rules for the contained elements. That is,
specify whether a contained element is optional or required, whether there can be
more than one, and what order contained elements must be in.
This section provides step-by-step instructions for defining the bookstore.dtd schema
file. You should perform the steps in each topic in the order of the topics. This section
includes the following topics:
From the Stylus Studio menu bar, select File > New > DTD Schema.
2.
Click Save
.
Stylus Studio displays the Save As dialog box.
61
4.
5.
2.
Click the DTD node at the top of the tree if it is not already selected.
3.
4.
62
7.
8.
To define the author element, repeat Step 2 through Step 7. In Step 4, type author
instead of title.
When you are done, the Stylus Studio desktop should resemble the following:
i
2.
3.
Click the book node in the DTD tree if it is not already selected.
2.
3.
In the drop-down list that appears, scroll down and double-click Sequence. This
indicates that the book element can include one or more elements.
63
5.
6.
7.
8.
Double-click One or More. (There can be one or more author elements in each book
element.)
9.
10.
At this point, the definition of the book element is complete, and the tree diagram of
bookstore.dtd should look like this:
However, you have not yet specified that you want the book element itself to be optional.
You need to do this in the element that references the book element. For example, suppose
the bookstore element is the root element in XML documents that use this DTD. Further
suppose that you want the book element to be a child of the bookstore element.
You can define the bookstore element as follows:
64
1.
2.
3.
4.
5.
7.
8.
Click Save
To complete this DTD, you could define magazine and newsletter elements. In the
bookstore element definition, you could add references to the magazine and newsletter
elements. You could also expand the definition of the book element to include information
about the publisher, price, publication date, and number of pages.
65
66
When you use the Diagram tab to define an XML Schema, you can create XML Schema
nodes directly on the XML Schema diagram pane using tools on the tool bar or from the
XML Schema > Diagram and shortcut menus. You can also type in the text pane, which
appears under the Diagram tab. The text pane displays the XML Schema syntax Stylus
Studio creates for you as you work in the diagram pane.
Stylus Studio ensures that the XML Schema you create is valid. For example, any nodes
you define are created in the required order in the XML document that contains the XML
Schema definition, regardless of the order in which you create them.
67
The Diagram tab, shown in Figure 50, consists of three main areas:
Diagram Pane
The diagram pane contains graphical representations of the elements, attributes, and other
nodes that make up your XML Schema.
Nodes
Each node displayed in the diagram pane is represented by its own symbol; tool tips,
which are displayed when you hover over a node in the diagram, identify the nodes type
68
(element, attribute, sequence, and so on). The symbols used in the diagram are
summarized in Table 1.
Table 1. Symbols Used in the XML Schema Diagram
Symbol
Represents
schema (xsd:schema)
annotation (xsd:annotation)
documentation (xsd:documentation)
element (xsd:element)
attribute (xsd:attribute)
attributeGroup (xsd:attributeGroup)
simpleType (xsd:simpleType)
complexType (xsd:complexType)
choice (xsd:choice)
sequence (xsd:sequence)
key (xsd:key)
key reference (xsd:keyref)
unique (xsd:unique)
group (xsd:group)
simpleContent (xsd:simpleContent)
complexContent (xsd:complexContent)
restriction (xsd:restriction)
extension (xsd:extension)
union (xsd:union)
list (xsd:list)
69
Nodes can be expanded and collapsed using the plus and minus symbols, respectively, that
appear on the right side of the node. In Figure 54 for example, the PurchaseOrderType
complexType has been expanded. The shipTo element has not.
Displaying Properties
To streamline the diagram, most nodes are displayed with their properties hidden by
default. Exceptions include element, extension, and restriction nodes, for which the type
is displayed, as shown in the productName element in Figure 52.
You can change the display for classes of nodes (all elements, for example) using the
Diagram Properties dialog box, shown in Figure 53. (In addition, the Properties window
70
If all of a nodes properties have the same show/hide setting, that value is displayed in the
Inline Visibility in Diagram field. If no value is displayed in the Inline Visibility in Diagram
field, it means that two or more properties have different show/hide settings.
To display the Diagram Properties dialog box:
Tip You can also change schema diagram properties on the Diagram page of the Options
dialog box Tools > Options > Module Settings > XML Schema Editor > Schema
Details.
Display the Diagram Properties dialog box, or the Schema Details page of the
Options dialog box.
2.
Tip
3.
Click OK.
Background color
Background color is used as another visual cue for information about the XML Schema:
A tan, or light brown, color identifies global nodes these are elements, types, and so
on, that are defined as children of the schema (xsd:schema). In Figure 54, the
purchaseOrder element is an example of a globally defined node.
71
Displaying documentation
By default, text associated with documentation elements (xsd:documentation) is hidden.
You can expand documentation elements in the diagram by clicking the Show
Documenation ( ) button, or by selecting Diagram > Show Documentation from the
Stylus Studio menu. When you do, the text associated with all documentation elements
defined in the XML Schema appears, as shown in Figure 55.
To move from node to node in the diagram, press the arrow keys.
72
You can use the scroll bars to explore the diagram; the zoom slider lets you change
the magnification.
Click Go to Definition (
) on the shortcut menu to display a new page that shows
just the type definition.
Click Display Definition (
) on the shortcut menu to jump to the place in the XML
Schema where the type is defined.
Text Pane
The text pane appears directly beneath the XML Schema diagram pane. It displays the
XML Schema code represented by the nodes you create in the diagram. The default font
is Courier New, but you can change it to whatever font you want by clicking the Change
Font button (
).
Stylus Studio synchronizes the diagram and text views of the XML Schema any changes
you make in the diagram are reflected in the text pane, and vice versa. Synchronization
information is displayed in the bar that separates the diagram and text panes. Current
status is displayed on the right. When the two views are synchronized, Stylus Studio
displays this graphic:
. When Stylus Studio detects a change, such as a change to
the text, it displays a message and changes the status graphic, as shown in Figure 56.
73
Stylus Studio also flags any XML Schema errors in the text pane lines that contain errors
are identified with a red dot, and the type and location of the error is displayed in the status
area at the top of the text pane, as shown here:
When you click the error message, Stylus Studio jumps to that part of the XML Schema
containing the error. When you correct one error, information about the next error
detected by Stylus Studio (if any) is displayed in the status area.
You can use the splitter to resize the text pane to view more or less text, or you can hide
it entirely using the controls on the splitters right side.
Figure 58. Splitter Controls Change Size of Text and Diagram Panes
Stylus Studio supports back-mapping between the text pane and the XML Schema
diagram pane if you click a node in the diagram, Stylus Studio scrolls the text pane to
display the line of XML Schema that defines the node you clicked. A blue triangle is
displayed to the left of the exact line of code.
74
Definition Browser
The definition browser is a drop-down list that displays all the child nodes of the schema
node. It is located at the top of the Diagram tab.
When you select a node from the definition browser, Stylus Studio displays a new page in
the XML Schema diagram pane that shows the definition of the node you select. In
addition, the definition browser displays information about that node.
To return to the page you were viewing previously, press the back (
) button.
Note When you display a node using the definition browser, the focus of the text pane does not
change. Clicking the node jumps you to that part of the XML Schema where the node is
defined.
75
Drag-and-Drop on page 77
QuickEdit on page 78
Refactoring on page 79
Select XML Schema > Diagram > Add > Element from the main menu
76
In-place Editing
In-place editing allows you to change node names and properties directly in the diagram.
For example, say you want to change the value of the Mixed property of the
PurchaseOrderType complexType. Just double-click the property. Stylus Studio opens the
property for editing, as shown in Figure 61.
Similarly, if you double-click a node name, Stylus Studio places the property in edit
mode, allowing you to type a new name.
Tip To display all of a nodes properties in the diagram, see Displaying Properties on
page 70.
Drag-and-Drop
An alternative to using the menu and the tool bar is to use drag-and-drop, which lets you
add an existing node to another nodes definition. For example, say you wanted to add an
existing element to a sequence. You can do this by dragging the element icon to the
sequence icon, as shown in Figure 62.
Use drag-and-drop any time you want to define a node using a node already defined in
your XML Schema.
Tip When you drag and drop, you remove the element from its current context. If you want
to make a copy an element, press and hold the CTRL key when you perform the drag
operation.
Typical targets of drag-and-drop operations include the following nodes
77
schema
sequence
choice
all
list
annotation
restriction
union
simpleType
element
annotation
Tip Any node you drag to the schema node is created as a child of the schema node.
QuickEdit
QuickEdit is a feature of the Diagram tab that streamlines common editing operations. For
example, you can use QuickEdit to
QuickEdit appears on the top-level and shortcut menus in those contexts in which it is
available, and it is also available on the tool bar by pressing the QuickEdit button .
78
Refactoring
Refactoring is a process that allows you to copy globally defined nodes from one XML
Schema and paste them in a new XML Schema. The difference between refactoring and
a simple copy is that refactoring includes both the node you select and all its
dependencies. Consider the following example: here is how the purchaseOrder node
appears when it is copied from purchaseOrder.xsd and pasted into a new XML Schema
document:
79
As you can see, the copy action copies only the selected node to the clipboard. When the
same node is copied using refactoring and pasted into another XML Schema document,
the node, and all its dependencies copied as well.
Not all of the diagram or text are displayed in this illustration, but it is clear that more than
just the purchaseOrder node was copied to the clipboard. For example, the
purchaseOrders type, PurchaseOrderType complexType has been copied, as well as
PurchaseOrderTypes element and sequence nodes, such as shipTo, billTo, and items.
If you were to scroll up either the text pane or the diagram pane, you would also see, for
example, the complete definitions for other global complexTypes such as SKU and
USAddress.
To refactor a node:
Note
1.
2.
80
To paste the node in the target XML Schema document, select Refactoring > Paste
from the shortcut menu.
The genre attribute specifies the style of the publication. That is, whether it is a book,
magazine, or newsletter.
There must be at least one author element and there can be more. Each author
element contains one first-name element and one last-name element.
ISBNnumber
PUBnumber
LOCnumber
The following topics in this section describe how to define this XML Schema using the
Diagram tab of the XML Schema Editor.
81
82
1.
From the Stylus Studio menu bar, select File > New > XML Schema.
Stylus Studio displays the XML Schema Editor. Maximize the XML Schema Editor
window. If the Project window is visible, you can close it.
2.
At the bottom of the XML Schema editor, click the Diagram tab.
Stylus Studio displays the Diagram view for the new schema.
Right-click the schema node in the XML Schema diagram pane and select Add >
ComplexType from the shortcut menu.
Alternatives: This action is also available from the XMLSchema > Grid Editing menu.
83
Stylus Studio displays a representation for the new node in the diagram. The
complexType properties appear in the Properties window. The new complexType has
a default name of ComplexType-0.
Type PublicationType in the Name property in the Properties window and press
Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
5.
Click Save
6.
In the Save As dialog box, in the URL field, type bookstoreDiagram.xsd, and click
Save. You can save it in the examples directory of the Stylus Studio installation
directory or in a directory of your choice.
2.
84
3.
In the Properties window, type genre as the name of the new attribute and press Enter.
4.
Scroll down to xsd:string and click it, or type xsd:string and press Enter.
The diagram should now look like the one shown in Figure 69.
You can toggle the display of attributes by clicking the small triangle at the bottom of
the complexType node.
Tip
6.
Click Save
2.
3.
4.
5.
6.
In the Properties window, click the Name field and enter title.
7.
8.
Scroll down to xsd:string and click it, or type xsd:string and press Enter.
85
According to the XML Schema requirements described earlier, the title element can
occur only once. By default, the default value for the Min Occur. (minimum occurrences)
and Max Occur. (maximum occurrences) properties is 1. You want exactly one instance of
the title element in PublicationType, so you can accept these defaults.
2.
3.
4.
5.
6.
Click Save
.
At this point, the XML Schema diagram should look like Figure 70:
86
element. Further, an author element must include a first-name element and a last-name
element.
Each element that can contain one or more subelements is a complexType. Consequently,
to add the author element to the PublicationType complexType, you must first define the
AuthorType complexType. You can then add an element that is of AuthorType to the
PublicationType complexType.
To define the AuthorType complexType:
1.
Right-click the schema node in the XML Schema diagram pane and select Add >
Complex Type from the shortcut menu.
Alternatives: This action is also available from the XMLSchema > Grid Editing menu.
Stylus Studio displays a representation for the new node in the diagram. The
complexType properties appear in the Properties window.
2.
Type AuthorType in the Name property in the Properties window and press Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
3.
4.
5.
6.
7.
Type first-name in the Name property in the Properties window and press Enter.
8.
9.
Repeat Step 5 through Step 8 to add a new element to the sequence, using last-name
as the name of the new element.
Now you can add the author element to the PublicationType complexType:
1.
2.
3.
Type author in the Name property in the Properties window and press Enter.
Stylus Studio updates the diagram and the XML Schema in the text pane.
87
Click the Type field in the Properties window. Stylus Studio displays a drop-down
list of built-in types plus any types you have defined, such as the AuthorType you
defined in the previous procedure.
5.
Tip
6.
7.
Tip
8.
Click Save
.
At this point, the XML Schema diagram should look like Figure 71:
88
2.
3.
Right-click the new sequence node. In the shortcut menu that appears, select
QuickEdit > Switch to Choice.
Stylus Studio changes the sequence node to the choice node ( ).
4.
5.
6.
In the Properties window, change the Name to ISBNnumber and press Enter.
7.
In the Properties window, change the Type xsd:int and press Enter.
8.
Repeat Step 4 through Step 7 twice: once to add the PUBnumber element, and once to
add the LOCnumber element.
9.
Click Save
89
The definition of the PublicationType complexType is now complete and should look like
Figure 72:
90
1.
2.
Stylus Studio displays a node for the new element in the XML Schema diagram pane.
The properties for the new element appear in the Properties window.
3.
Type book as the name of the new element and press Enter.
4.
In the Properties window, click the Data Type field. Stylus Studio displays a dropdown list of built-in types plus any types you have defined.
5.
Click PublicationType.
6.
Repeat Step 1 through Step 5 twice: once to add the magazine element, and once to
add the newsletter element.
7.
Click Save
.
The bookstoreDiagram.xsd document is now complete.
8.
Select XMLSchema > Validate Document from the menu to validate the XML Schema
document you created.
The validation message appears in the Output window, as shown in Figure 73.
91
opens any files that were open the last time you closed Stylus Studio. See Options Application Settings on page 1321.
92
.conv
.dff
.dtd
.java
Java Debugger
.pipeline
XML Pipline
.prj
Project framework
.report
XML Publisher
.sef
.wscc, .wsc
.wsdl
.xml
XML Editor
.xquery
XQuery Editor
.xsd
.xsl, .xslt
You can add your own file types to this list, specify the module you want them opened in,
and, optionally, specify Stylus Studio as the default application for viewing and editing
files of that type. See Adding File Types to Stylus Studio on page 99.
When you respond to this dialog box, you can optionally indicate whether you want all
files of that type to be associated with the Stylus Studio module you select in the future.
File types you associate with a Stylus Studio module are added to the File Types page of
the Options dialog box. You can remove or change the module association at any time.
See Adding File Types to Stylus Studio on page 99 for more information.
93
See Integrating with Third-Party File Systems on page 1163 for more information.
By default, the File Explorer window appears on the right side of the Stylus Studio
window, but you can drag it anywhere on your desktop. You can close/open the File
Explorer window from the View menu.
94
Right-click the file and select Open or Open With from the shortcut menu
Open With allows you to select the module you want to use to open the file.
Tip
Drag and drop the file. See Dragging and Dropping Files in the Stylus Studio on
page 97.
When you open a file by double-clicking or using the Open shortcut menu, Stylus Studio
opens the file in the module associated with the file type (the XML Editor for .xml files,
for example). If the file type is not currently registered with Stylus Studio, you can register
the file at this time using the Choose Module for dialog box. See Types of Files
Recognized by Stylus Studio on page 92 for more information about file type/module
associations in Stylus Studio.
95
Description
Creates a new folder as a child of the folder with current focus. The
default folder name is New Folder.
Displays the structure of XML documents in tree form. You can
drag exposed nodes onto the document tab area to open the
document associated with that node. If you drag a node into an
existing XQuery or XSLT document, Stylus Studio creates the
document function with the XPath expression for that node. For
example, if you drag the title element from books.xml into an
XQuery document, Stylus Studio builds the following function:
doc("file:///c:/Program Files/Stylus Studio X14 XML
Enterprise Suite/examples/simpleMappings/
books.xml")/books/book/title
Refresh
Reset Filters
Resets the File Explorer filter from its current content to the
wildcard (*.*).
Changes the File Explorer filter to display only file types associated
with Stylus Studio: .xml, .xsd, .dtd, .java, .conv, and others.
You can
Type your own filter (*.txt, for example). If you want to use multiple filters, separate
them with a semicolon (*.txt; *.html, for example).
In an active document
Adds the file to the project. If the file type is not currently
registered with Stylus Studio, you can register the file at
this time using the Choose Module for dialog box. See
Opening Unknown File Types on page 93.
97
The Open dialog box (displayed when you select File > Open from the menu, for
example). By default, Stylus Studio opens the file in the editor associated with files
of the type you select (see Types of Files Recognized by Stylus Studio on page 92).
If you want, you can choose a different editor you might want to open an XSLT
stylesheet in the XML Editor, for example when opening files from the Open dialog
box.
To specify a different module, click the down arrow to the right of the Open button
and select the module you want to use from the drop-down list as shown in Figure 78.
98
Project window either double-click the file, or select Open or Open With from the
files shortcut menu.
Other file system browsers (like Windows Explorer, for example) for files
recognized by Stylus Studio, just double-click the file. See Opening Unknown File
Types on page 93.
procedure described in this section for file name extensions peculiar to your application
or environment.
To add a file type to Stylus Studio:
1.
From the Stylus Studio menu bar, select Tools > Options.
Stylus Studio displays the Options dialog box.
2.
99
button.
4.
Type the new extension, including the period, and press Enter.
Stylus Studio adds the file type and selects a default module in the Module field.
5.
Optionally, select a different module using the drop-down list in the Module field.
6.
If you want to always use Stylus Studio to open files of this type, change the value in
the Open with Stylus Studio field to True.
7.
8.
2.
3.
Click OK.
button.
100
There are several ways to toggle the display of the Project window. You might want to
close the Project window in order to gain more space in the editor you are working with,
for example.
101
From the Stylus Studio menu, select View > Project Window.
In the Stylus Studio tool bar, click Toggle Project Window
.
Tip The Project window is dockable you can move it anywhere on your desktop.
2.
3.
Other Documents
Stylus Studio displays documents that are not associated with a project in the Other
Documents folder, which appears after the last folder or document in the currently
displayed project. In addition, when you remove a file from a project, it is placed in the
Other Documents folder.
You can add these documents to a project at any time. See Adding Files to Projects on
page 104.
102
Stylus Studio displays the new project in the Project window. The Project window
displays information for only one project at a time.
To create a subproject:
1.
Right-click the project name, and click New Project Folder in the pop-up menu.
Stylus Studio displays a default subproject folder name (NewFolder1, for example).
2.
3.
Press Enter.
There are several ways to add files to your projects and subprojects. See Adding Files to
Projects on page 104.
Saving Projects
To save a project, select Project > Save Project.
The first time you save a project, Stylus Studio prompts you to specify a name for your
project. Stylus Studio appends .prj to the name you specify. It does not matter whether
or not you specify the .prj extension. Stylus Studio does not allow a project to have any
other file name extension.
When you save a project, references to the files part of the project are saved relative to the
path of the project file. This allows you to move or share projects easily.
Opening Projects
You can have only one project open at one time. If you have a project open and you open
a second project, Stylus Studio closes the first project and then opens the second project.
If the Project window is not visible when you open a project, Stylus Studio automatically
displays the Project window.
103
From the Stylus Studio menu bar, select Project > Open Project.
2.
Navigate to and select your project file. For example, you can open examples.prj in
the examples directory of your Stylus Studio installation directory. The examples
project contains the files for all Stylus Studio sample applications.
3.
Figure 82. Recently Opened Projects Are Listed on the Project Menu
104
2.
Click the window (the Web Service Call Composer, for example) that contains the file
you want to add.
3.
2.
3.
Navigate to the file you want to add and click the Open button.
Copying Projects
To copy a project:
1.
2.
From the Stylus Studio menu bar, select Project > Save Project As.
The Save As dialog box appears.
3.
4.
5.
105
2.
3.
in the Stylus
in the Stylus
2.
In the Project window, click the path for the file you want to remove.
3.
From the Stylus Studio menu bar, select Project > Remove File from Project.
Alternative: Press the Delete key.
106
Deleting
To delete a project, remove its .prj file from the file system.
2.
3.
107
5.
To add a JAR file to the classpath, click the browse jar files button (
Stylus Studio displays the Browse for Jar Files dialog box.
).
108
).
When you have located the JAR file or folder you want to add to the classpath, click
OK.
7.
Optionally, add other JAR files or folders to the classpath by repeating Step 5 and
Step 6.
Check in a file
109
In this section
This section covers the following topics:
Clearcase/Attache
CVS
Prerequisites
To use Stylus Studios source control features, you must have already installed the client
software for your source control application, as shown in Table 5.
Table 5. Working with Source Control Clients
When Data Is In
SourceSafe repository
ClearCase
Attache client
CVS
Zeus-CVS product
In addition, files must belong to a Stylus Studio project before you can use them with a
source control application.
Recursive Selection
When you build a project using files from a source control application, Stylus Studio gives
you the option of recursively importing all projects that are subordinate to the project
folder you select. This option, Recursively import all subprojects, appears on the Build
Project from SCC dialog box, which appears when you start the New Project Wizard.
110
Selecting the Recursively import all subprojects option has the effect of selecting all the
siblings of the selected file or directory, as well as any descendants of the selected item
and its siblings. Stylus Studio creates a project that contains all files that Stylus Studio can
open (for example, .xml, xslt, and .xsd files) and that are in the directory hierarchy of the
file or directory you select.
For example, suppose you check Recursively import all subprojects, and you select
c:\work\myproject\documentation.xml. Stylus Studio creates a project that contains all
Stylus Studio-editable files in c:\work\myproject and its subdirectories.
If you do not check Recursively import all subprojects, only the file you select is added
to the new Stylus Studio project you create. You cannot select a directory if you do not
select this option.
From the Stylus Studio menu bar, select Project > New Project Wizard.
The Project Wizards dialog box appears.
111
Select Microsoft Visual Sourcesafe from the Provider to use drop-down list.
4.
If you want to use Stylus Studio to access more than one file in a directory hierarchy,
click the check box for Recursively import all subprojects. See Recursive
Selection on page 110 if you need help with this step.
Depending on your installation, you might need to specify other properties. See
Specifying Advanced Source Control Properties on page 117.
5.
112
6.
Specify the username and password; optionally, use the Browse... button to access a
database other than the default database displayed in the Database field.
7.
Click OK.
Select the folder in which you want to create the new project.
9.
Click OK.
The project is created in Stylus Studio. A message displays the names of any files that
were not added to the project because their extensions are not associated with a Stylus
Studio editor.
Use Attache to copy the files you want to work on from a ClearCase view to the local
file system.
If you move these files from this directory after you create the project, you must
specify the new directory that contains the files in the Local Project Path field of the
Source Control Properties dialog box. To access this dialog box, select
SourceControl > Source Control Properties from the Stylus Studio menu bar.
Note
2.
From the Stylus Studio menu bar, select Project > New Project Wizard.
113
114
4.
5.
If you want to use Stylus Studio to access more than one file in a directory hierarchy,
click the check box for Recursively import all subprojects. See Recursive
Selection on page 110 if you need help with this step.
Depending on your installation, you might need to specify other properties. See
Specifying Advanced Source Control Properties on page 117.
6.
Navigate to and select the file or directory you want to operate on, or one of the files
or directories in the topmost level of the directory hierarchy that you want to access,
and click the OK button.
Stylus Studio creates a new project that contains the file you selected, or all files that
are editable by Stylus Studio and that were in the directory hierarchy of the file you
selected. The default name of the project is Projectn. To rename the project, select
Project > Save Project As from the Stylus Studio menu bar.
115
From the Stylus Studio menu bar, select Project > New Project Wizard.
The Project Wizards dialog box appears.
2.
3.
4.
5.
6.
In the User Name field, type the user name you want to use to log in to the CVS server.
7.
In the Project Name field, type the name of a module in the source control hierarchy.
This should be the name of a directory that contains all files that you want to open in
Stylus Studio.
8.
In the Auxiliary Path field, type the contents of the CVSROOT environment variable that
you use to access the CVS server.
For example, suppose you are required to enter the following commands in a DOS
console or UNIX shell:
cvs.exe -d:pserver:[email protected]:/cvsroot/projectname login
Password: *****
cvs.exe -d:pserver:[email protected]:/cvsroot/projectname co module
The value you should enter in the Auxiliary Path field would be:
:pserver:[email protected]:/cvsroot/projectname
9.
116
All files that can be opened in Stylus Studio are now in the new Stylus Studio project. The
default name of the project is Projectn. To rename the project, select File > Project > Save
Project As from the Stylus Studio menu bar.
The cvs.exe file must be in your PATH environment variable.
Note
User Name is the name of the source control user. Stylus Studio uses this name to
117
allows you to enter any other information required to find your source control server.
For example, if you are using SourceSafe, you would specify the directory of the
SourceSafe client here. If you are using CVS, you would specify the contents of the
CVSROOT environment variable.
Working Dir is the local directory into which you copied the files under source control
that you want to access. It is the local counterpart for the source control repository.
For example, suppose you copied the contents of the SourceSafe repository
$/Company/OneProject to the local directory c:\work\myproject. Your local files
would map to the source control hierarchy as shown in Table 6:
Repository File
c:\work\myproject\documentation.xml
$/Company/OneProject/documentation.xml
c:\work\myproject\subdir\root.java
$/Company/OneProject/subdir/root.java
c:\work\anotherproject\root.java
$/Company/anotherproject/root.java
Show/hide
Group position
Tip Tool bars are docking windows you can drag them anywhere on your desktop.
118
You control all these customizations from the Toolbars tab of the Customize dialog box.
2.
In the Toolbars group box, deselect the check box of the group you want to hide.
The tool bar is removed from the Stylus Studio window.
3.
To re-display a hidden tool bar group, follow Step 1 and Step 2 and reselect the check
box,
119
Whether or not to show tooltips when the mouse pointer is placed over a tool bar
button
Whether tool bar buttons are rendered in a size larger than the default
Note Appearance settings affect all tool bars. You cannot control the appearance of individual
2.
Click Show Tooltips to toggle the display of tooltips when the pointer is placed over
a tool bar button.
3.
Click Large Buttons to toggle the size of the tool bar buttons.
4.
5.
120
1.
From the Stylus Studio menu bar, select Tools > Options.
2.
In the Options dialog box that appears, expand Module Settings to display a list of
choices.
XML Diff
You use the Engine and Presentation pages to define settings used by the XML Diff tool.
See Diffing Folders and XML Documents on page 176 for more information.
XML Editor
Click XML Settings to specify the following:
Number of errors after which you want Stylus Studio to stop validation, and whether
or not you want Stylus Studio to display a message when validation is complete
Click Custom Validation Engines to specify an alternate validation engine. See Custom
XML Validation Engines on page 1170 for more information.
XSLT Editor
Module settings for the XSLT Editor let you specify external XSLT processors, settings
used by the Mapper tab, and general editor behavior.
Click External XSLT to specify default values for external XSLT processors. Note that
Stylus Studios back-mapping and debugging features are not supported for all XSLT
processors. The XSLT processors that support back-mapping and debugging are
identified on the Processor tab of the Scenario Properties dialog box.
In a scenario, you can specify that you want to use an external XSLT processor. If you use
a particular XSLT processor frequently, specify default values here. Then, in the scenario
properties, you just need to specify which external XSLT processor you want to use. If
you specify default values and you then specify different values in a scenarios properties,
the scenario properties override the defaults. You can specify the following external XSLT
options:
121
Whether Stylus Studio displays the Scenario Properties dialog box when you create
a new stylesheet
Java
To modify Java settings, see Configuring Java Components on page 133.
122
1.
From the Stylus Studio menu bar, select Tools > Options.
Stylus Studio displays the Options dialog box.
2.
Enter the name as you want it to appear in the Stylus Studio Tools menu.
5.
In the Command field, specify or select the absolute path for the command that runs
your tool. This must be a .exe, .bat, or .cmd file.
6.
In the Arguments field, specify any arguments your tool requires. You can click
to display a drop-down list that includes File Path, File Dir, File Name, File Extension,
and Classpath.
7.
In the Initial Directory field, type the absolute path for the directory that contains any
files or directories needed by your custom tool.
8.
In the Path field, type any paths that need to be defined and that are not already
defined in your PATH environment variable.
9.
If you want Stylus Studio to prompt for arguments before it runs your tool, click
Prompt for Arguments.
10.
If you want Stylus Studio to display output from your custom tool in its Output
Window, select Use Output Window.
123
If you want Stylus Studio to save all open documents before running this tool, select
Save All documents before execution.
12.
Example:
struzzo /newCustomTool "Tool 0:=Tool 0;Description=Avalon Uploader;
Command=AVRPTLDR.exe;Args= ${FilePath}"
Arguments for the newCustomTool function are described in the following table:
Table 7. Properties for Registering Custom Tools
Name
Description
Tool n:
The full syntax for this property is Tool n:=Tool n, where n is some
number. The number, n, specifies the order in the Tools menu in
which the custom tool you are registering appears. You might use 0
for the first tool you register, 1 for the second, and so on. Valid
values are numbers starting with 0.
The first part (Tools n:=) is used to create a key in the Windows
registry. The second part (Tools n) is used as a prefix for other
entries in the registry key that correspond to this tool. The two
values should always be the same (Tools 1:=Tools 1, for example).
124
Args
Command
The absolute path for the command that runs your tool. This must be
a .exe, .bat, or .cmd file.
Description
The tool name as you want it to appear on the Stylus Studio Tools
menu.
Description
Initial Directory
The working directory for the tool. This is the absolute path for the
directory that contains any files or directories needed by your
custom tool.
Path
Any paths that need to be defined and that are not already defined in
your PATH environment variable.
PromptArgs
RedirectOutput
Whether you want the output directed to the Stylus Studio Output
window. Valid values are 0 (do not redirect) and 1 (redirect).
DoSaveAll
Whether you want Stylus Studio to save all open documents before
running this tool. Valid values are 0 (do not save) and 1 (save all).
1.
From the Stylus Studio menu bar, select Tools > Keyboard.
125
Tip
126
In the Select a macro: field, select the macro for which you want to define a shortcut.
When you select a macro, Stylus Studio displays a description of what that macro
does.
Press the key or keys that you want to be the shortcut. For example, Ctrl+E, F7, Alt+P.
The Assign Shortcut dialog box displays a message indicating whether or not that
key combination is currently in use.
5.
If the shortcut key is not already in use, click the OK button. Otherwise, try another
shortcut key.
Stylus Studio closes the Assign Shortcut dialog box.
6.
To delete a shortcut:
1.
From the Stylus Studio menu bar, select Tools > Keyboard. The Shortcut Keys dialog
box appears.
2.
In the Select a macro: field, select the macro you want to delete a shortcut for.
3.
In the Assigned shortcuts field, click the shortcut you want to remove.
4.
Click Remove.
5.
127
Description
struzzo
StylusDiff
StylusValidator
Validates XML
You can also execute DataDirect XML Converters (componentst that let you convert
non-XML like EDI and CSV to XML, and vice versa) from the command line. To learn
more about the DataDirect XML Converters for Java and .NET, see the DataDirect
XML Converters documentation at
http://www.datadirect.com/techres/xmlconvertersproddoc/index.ssp.
128
or XQuery
Description
file
The path of the document you want to open in Stylus Studio. This document
is used as the source document in a scenario when you provide the
stylesheet or XQuery parameter.
[stylesheet or
XQuery]
The path of the stylesheet or XQuery you want to use to create a scenario.
Description
[-q]
[-noval]
[-schema file]
Validates the XML document against the XML Schema specified in the file
parameter.
filename
129
Troubleshooting Performance
Table 11, Performance Symptoms, summarizes performance symptoms you might
experience and where to find information on addressing them.
Table 11. Performance Symptoms
Symptom
See
130
information can affect XML editing performance. The default refresh interval is 10
seconds.
If XML editing performance is slow, increase the refresh interval that Stylus Studio uses
to refresh the schema information.
To change the refresh interval:
1.
From the Stylus Studio menu bar, select Tools > Options.
The Options dialog box appears.
2.
3.
Tip
4.
Click OK.
From the Stylus Studio menu bar, select Tools > Options.
The Options dialog box appears.
2.
3.
If the Automatically check for externally modified files is selected, deselect it.
Alternatively, you can select Disable check on hidden files, which allows Stylus
Studio to skip these files. Hidden files are files that are in the Stylus Studio project or
the Other Documents folder but are not currently open in Stylus Studio.
4.
Click OK.
131
The Maximum recursion level is the number of levels Stylus Studio allows you to
recurse on a template invocation.
The Allocated stack size is the amount of memory allocated to the XSLT processing
thread stack.
To change the recursion level or the allocated stack size:
1.
From the Stylus Studio menu bar, select Tools > Options.
The Options dialog box appears.
2.
3.
Adjust the Maximum recursion level and the Allocated stack size as needed. For
information about how Stylus Studio uses these settings see Options - Module
Settings - XSLT Editor - XSLT Settings on page 1366.
4.
Click OK.
Close most or all files before you shut down Stylus Studio.
Turn off the option that automatically opens the files that were open the last time you
closed Stylus Studio.
To prevent Stylus Studio from automatically opening documents:
132
1.
From the Stylus Studio menu bar, select Tools > Options.
The Options dialog box appears.
2.
If Open last documents automatically when Stylus Studio starts is selected, deselect
it. For information about how Stylus Studio uses this settings see Options Application Settings on page 1321.
4.
Click OK.
FOP
133
Rather than trying to determine in advance which Stylus Studio modules you might use
in your XML application development, consider installing the JDK or JRE on your
machine.
The Java Virtual Machine field displays information about the JVM installed on your
machine.
134
Once these properties have values, Stylus Studio uses them until you either
Use the auto detect feature to change them. You might want use auto detect if you
have been using Stylus Studio with the J2SE 1.4.2 and later install the J2SE 5.0, for
example.
Change them manually. You can manually specify that Stylus Studio use a different
jvm.dll or javac.exe, for example.
135
Note that if you manually change your settings to use another local version of the JDK, it
may fail to load properly unless you also point the Current Version setting to match. This
is because the JVM itself might try to load DLLs from the location of the current version
instead of the location you specify.
136
1.
Start Stylus Studio if it is not already running, and select Tools > Options from the
menu.
The Options dialog box appears.
2.
3.
If you want Stylus Studio to update Java component properties to the latest installed
version on you machine, click the Auto detect button.
Otherwise, make the changes manually.
4.
Click OK.
5.
If you made changes to any JVM properties, you need to restart Stylus Studio for
those changes to take effect.
Chapter 2
Stylus Studio makes it easy to create, edit, and query XML documents. Depending on the
structure of the data in your XML document, you can choose to work with raw XML text,
a DOM tree diagram, or a grid representation. Any changes you make in one view are
immediately visible in every other view. You can easily create an XML Schema or DTD
based on the content of your XML document if it is not already associated with a schema.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XML Editor video.
You can see other Stylus Studio video demonstrations here:
http://www.stylusstudio.com/xml_videos.html.
This section covers the following topics:
137
The XML Editor provides several views of an XML document, each on its own tab Text,
Tree, Grid, and Schema. See Updating an XML Document Getting Started on page 10
for an overview of these XML editing tools. See Updating XML Documents on
page 141 for more detailed information.
Document wizards that convert HTML, DTD, and XML Schema to XML. See Using
Document Wizards to Create XML on page 139, later in this section.
DataDirect XML Converters, which convert CSV, fixed-width, EDI, and other flat file
formats to XML. See How XML Converters are Used in Stylus Studio on page 214.
Custom XML conversions that you build using Stylus Studios Custom XML
Conversion module. See Custom XML Conversions on page 221.
DataDirect XML Converters and the Stylus Studio Custom XML Conversions
module are available only in Stylus Studio XML Enterprise Suite.
138
2.
Specify the file from which you want to create an XML document (an HTML file or
an XML Schema, for example).
3.
Specify additional settings that will affect the resulting XML document (the root
node, for example).
4.
All document wizards are listed in the Document Wizards dialog box. Select File >
Document Wizards to display this dialog box.
element in the XML document is created using the minimum value of the range specified
for that type. For example, if the XML Schema contains a <part> element defined as
type=xs:integer, the <part> element in the resulting XML document appears as
<part>-9223372036854775808</part>.
139
140
Choosing a View
You can add and modify the data and structure of an XML document in any view. When
you switch to a different view, any changes you made appear in the new view. To move
from view to view, click the Text, Tree, or Grid tab at the bottom of the document you are
working with.
To add contents to an empty XML document, consider the structure of the data you plan
to add. The Grid view is most useful for creating very structured data that includes
multiple instances of the same elements. The Tree view makes it easy to add many
different elements. In order to use it, however, the XML must be well-formed.
Each view of the document allows you to query the contents of the document. See
Querying XML Documents Using XPath on page 210.
Watch it! You can view a video demonstration of the Grid tab by clicking the
television icon or by clicking this link: watch the XML Grid Editor video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
141
Ensuring Well-Formedness
To ensure that your XML document is well formed, click the Tree tab at the bottom
of the XML editor window.
If the document is well formed, Stylus Studio displays the tree representation. If the
document is not well formed, Stylus Studio displays a message that indicates the reason
the document is not well formed and the location of the error or omission. Correct the
document, and click the Tree tab.
If you are already viewing the Tree representation of your document, the document is well
formed. When you edit the Tree view, the XML that Stylus Studio generates is always
well formed.
142
In the File Explorer, navigate to the JSP file you want to open.
2.
Right click the file name, and select Open With from the shortcut menu.
3.
143
Click the right mouse button to display a pop-up menu of edit commands.
Press the standard control keys to copy, cut, paste, undo, or redo.
You can select a portion of text and move it to a new location by dragging it. You can drag
text from one document to another. You can drag text from documents outside Stylus
Studio to a document in Stylus Studio.
Code Folding
Code folding is the ability to collapse three or more lines of code in XML-based editors.
For example, this code segment:
<author>
<first-name>Joe</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
Code folding allows you to simplify the visual presentation of XML-based code; folding
does not affect the underlying code.
In editors in which code folding is supported, Stylus Studio displays a tree control in the
gutter to the left of editing canvas; this is the same area of the editor used to display line
numbers, debugging symbols, and back mapping symbols. By default, all code is
displayed.
144
Internal DTD
Comments
CDATA
XML elements
In the XQuery Source editor, you can fold
Comments
XML elements
How to Fold Code
To unfold a segment of code, click the [-] symbol associated with that code.
When you fold code, Stylus Studio displays a boxed ellipsis symbol at the end of the line
of code you have folded, as shown here:
If you place the pointer in the ellipsis symbol, Stylus Studio displays a tool tip that shows
you the collapsed code. The amount of code that appears in the tool tip depends on the
area on your desktop you have given the Stylus Studio application.
Tip You can unfold a folded segment by double-clicking the tool tip.
145
elements that are allowed at that location of the document. As shown in Figure 103, there
are two entries for book, for example:
Use the arrow key to move the selection, and press Enter to insert the value you want.
Indent
Indent XML tags to show the hierarchy relationships. Click Indent XML Tags
Studio indents all text in the active XML document window.
. Stylus
Note After you click the Indent XML Tags button, you cannot automatically undo or redo any
changes you have been making. After you make more changes, you can press Ctrl+Z and
Ctrl+Y to automatically undo and redo those changes until you click Indent XML tags
again.
146
Line Wrap
Stylus Studio automatically wraps lines whose length exceeds 16k characters. You can
turn off this feature by selecting Disable from the Line wrap field on the Editor General
page of the Options dialog box (Tools > Options).
You can override line wrap settings by selecting Edit > Wrap Lines from the Stylus Studio
menu or by clicking the wrap lines button on the tool bar( ).
When line wrapping is on, Stylus Studio wraps lines to fit in the available window; the
place at which the line wraps moves as the width of the window changes. Green arrows,
as shown in Figure 105, indentify lines that have wrapped.
Spell Checking
By default, Stylus Studio spell checks text as you type using an internal spell checker.
Words the spell checker believes are misspelled (or repeated) are underlined with a
squiggly line, as shown in Figure 106.
For more information, see <hyperlink>Using the Spell Checker on page 151.
147
Font
You can change the font of the text display in Stylus Studio. This change affects only the
Stylus Studio display. Beyond personal preference, you might choose to change the font
for localization purposes the available fonts are the fonts that can display the characters
in your XML file. For example, in a Japanese file, only two or three font names appear.
Click Font Change
to display a list of fonts.
Comments
Select the text that you want to be a comment. In the Stylus Studio tool bar, click
Comment/Uncomment Selection
. To remove comment tags, select the commented
text, and click Comment/Uncomment Selection.
Tip To select an entire line, click the gray area to the left of the line you want to select.
Bookmarks
You can set bookmarks in the XML display. Bookmarks allow you to jump to important
lines in your file. See Using Bookmarks on page 556.
Search/Replace
Search for and replace text you specify. Click Find
You can also enable Find by pressing Ctrl + F.
or Replace
When you enable Find, Stylus Studio displays the word in which the cursor is located
whether the cursor is within the word or immediately adjacent to it in the Find what field
148
of the Find dialog box. Similarly, any text you have selected whole, partial, or multiple
words is displayed in the Find what field.
Tip You can scroll through a list of the other words you have searched for by clicking the
down arrow when the Find what field is active.
Note that in addition to specifying case, you can also indicate whether or not you want to
use regular expressions in the Find what field and Replace with field. This allows you, for
example, to search for a line and replace it with multiple lines, as shown in the following
example.
See Sample Regular Expressions on page 258 for examples of regular expressions and
to learn about other sources of information.
Type of Data
White
Document background
Royal blue
Markup
Black
Pale blue
Schema definition
149
Type of Data
Purple
Red
Attribute names
Dark blue
Attribute values
Orange
150
1.
2.
3.
4.
Set the font, size, and color for different document categories as desired.
5.
display a list of suggestions for the word identified by the Spell Checker.
151
Ignore the current occurrence of the word the Spell Checker has selected
Ignore all occurrences of the word
Replace the current occurence of the word
Replace all occurrences of the word
Add new words to the dictionary
Edit existing dictionary content
Words to skip based on certain characteristics you might decide to skip e-mail
addresses and URLs, for example. Skipped words are not considered by the Spell
Checker.
Characteristics in words that you wish to ignore you might not care about case or
accents marks for spelling purposes. In this case, two words that share the same
spelling, except for the characteristic you specify, are considered to be equivalent
(mme and meme (accent), or BMW and bmw (case), for example).
152
The type of dictionary you want the Spell Checker to use when providing alternatives
to the typographical errors it locates. Settings range from Abriged to Unabridged and
show the fewest to the most alternatives, respectively. The Abridged setting results in
fewer alternative suggestions for misspelled words than Standard (the default) or
Unabridged, for example, but it requires less time to spell check a given document.
The layout of the keyboard you are using. The Spell Checker uses this information to
offer meaningful suggestions to words you might have mistyped.
Then
2.
Click Add.
Once you select an action, the Spell Checker continues checking the document.
When you have addressed all identified errors in the document (either by replacing,
correcting, or ignoring them), the Spell Checker stops.
153
and Settings\username\
Warning Do not modify the files in this directory by hand. Use the Personal Dictionary Editor
Start the Spell Checker and display the Personal Dictionary Editor dialog box (click
Edit on the Spelling dialog box).
2.
3.
4.
Tip You can also add any word identified as a misspelling to the personal dictionary by
pressing the Add button on the Spelling dialog box.
154
1.
Start the Spell Checker and display the Personal Dictionary Editor dialog box (click
Edit on the Spelling dialog box).
2.
3.
Select the .txt file you want to import into the personal dictionary and click Open.
The words in the list you import appear in the Words in Personal Dictionary list box.
Stylus Studio User Guide
Start the Spell Checker and display the Personal Dictionary Editor dialog box (click
Edit on the Spelling dialog box).
2.
3.
Navigate to the directory in which you want to save the copy of the personal
dictionary.
4.
5.
Click Save.
The contents of the personal dictionary is saved to the text file.
6.
Line Numbers
To go to a particular line, click Go to a specified location
in the Stylus Studio tool
bar. Stylus Studio displays the Go To dialog box. Type the number of the line you want to
go to and click OK. The cursor moves to the line you specified.
Stylus Studio displays line numbers and column numbers in the lower right corner of the
Stylus Studio window. If you want, you can set a Stylus Studio option that displays line
numbers to the left of each line in the editor you are using.
To do this, from the Stylus Studio menu bar, select Tools > Options. In the Options page
that appears, click Editor General. In the Editor field, select the editor in which you want
to display line numbers. Select the Show Line Numbers check box.
155
Bookmarks
To quickly focus on a particular line, insert a bookmark for that line. You can insert any
number of bookmarks. You can insert bookmarks in any document that you can open in
Stylus Studio.
To insert a bookmark, click in the line that you want to have a bookmark. Then click
Toggle Bookmark
in the Stylus Studio tool bar. Stylus Studio inserts a turquoise box
with rounded corners to the left of the line that has the bookmark. To move from
or Previous Bookmark
. See
bookmark to bookmark, click Next Bookmark
Using Bookmarks on page 556.
Tags
To move to the closing tag for an element, click in the tag name for the element. In the
. Stylus Studio moves the cursor to
Stylus Studio tool bar, click Go to Matching Tag
the closing tag for the element you clicked.
Find
In any view of an XML document, and in the XSLT Source view of a stylesheet, you can
in the Stylus Studio tool bar. In the Find dialog box that appears, specify
click Find
the string you want to search for and click Find Next. Stylus Studio highlights the first
occurrence of the string you entered. In the Text view, you can specify that you want
Stylus Studio to highlight all instances.
Depending on which view you are examining, Stylus Studio allows you to specify
constraints on the search. The constraints you can specify include the following:
Match case
Search inside only element tags, only element values, only attribute names, and/or
only attribute values
To learn more about regular expression syntax, visit
http://www.boost.org/libs/regex/doc/syntax.html.
156
While you are editing, if the display does not appear to correctly represent the current tree,
in the main tool bar. If you want to perform a certain action
click Reload Document
and Stylus Studio has grayed out the button for that action, try clicking Refresh first.
To save your file, select File > Save from the Stylus Studio menu bar or click Save in the
Stylus Studio tool bar.
This section discusses the following topics:
Changing the Name or Value of a Node in the Tree View on page 159
Stylus Studio User Guide
157
158
1.
Click the element that you want to be the parent of the new element, or click an
element that you want to be a sibling of the new element.
2.
3.
Double-click the element you want to add, or type the name of the new element and
press Enter. If you added a child node, Stylus Studio adds it as the last child.
4.
If the new element contains data, type a value for the new element and press Enter.
2.
2.
Click the up and down arrows at the top of the document window to move the node
up or down the tree.
Alternative: Drag the node to its new location.
2.
3.
Double-click the new name, or type the new name and press Enter.
159
2.
3.
160
1.
2.
Right-click the node for which you want the XPath expression.
3.
In the shortcut menu that appears, click Copy XPath Query to Clipboard.
4.
Press Ctrl+V to paste the XPath expression where you want it.
This section describes the features of the Grid tab and how to use it to edit XML
documents. This section covers the following topics:
161
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XML Grid Editor video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
162
A plus sign displayed to the left of the node name indicates that this node has child nodes.
You can click the plus sign to display a subgrid that displays the child nodes, as shown in
Figure 114.
You can continue to drill down in this fashion to view all values.
To expand a node, click the plus sign (
).
163
element is simply a container for one or more <author> elements, as shown in this excerpt
of books.xml:
<authors>
<author>David A. Chappel</author>
<author>Tyler Jewell</author>
</authors>
To streamline the display, Stylus Studio hides the tables that represent container nodes.
Information about container nodes is displayed in the child nodes header. Figure 115
shows the default display for the author element. Notice that the header,
book/authors/author, contains information about the container node, authors.
If you want, however, you can display the tables associated with container nodes, as
shown in Figure 116.
164
The table associated with the authors node now appears in the grid; it is empty (it has no
rows) because it is a container. The elements it contains are displayed in their own table,
authors/author.
To display container nodes, click Simplified View (
).
This action is also available from the XML > Grid Editing menu and from the grid shortcut
menu.
Renaming Nodes
You can rename container nodes directly in the grid.
To rename a node:
1.
Double-click the header that represents the node you want to rename.
The node name is selected.
2.
3.
Resizing Columns
When you expand a node, Stylus Studio displays it in uniform columns. You can resize
columns to any width you prefer by dragging the handle on the right side of the column
header, as shown in Figure 117.
165
).
This action is also available from the XML > Grid Editing menu.
166
Key
Action
Moves the row highlight in the direction of the arrow key you press.
Moves the focus from one cell to the next, in the direction of the
arrow key you press.
Page Up
Action
Page Down
Tab
Moves the focus forward to the next cell in the row; moves to the
first cell of the next row when you hit the last cell in a row.
Shift + Tab
Moves the focus backward to the previous cell in the row; moves to
the last cell of the previous row when you hit the first cell in a row.
The row is selected; you can perform row-oriented actions like changing the rows
order in the table. You can also select a row by clicking the plus sign to the left side
of the row.
The column is selected; you can perform column-oriented actions like adding a new
column or renaming an existing one.
167
If you move the rows in the authors table, for example, as shown in Figure 119,
168
Reordering Rows
You can move rows up and down within the same table. Changes you make to row order
affect the element order in the underlying XML document.
To move a row:
1.
2.
Click the Move Up ( ) or Move Down ( ) button to move the row to the desired
location in the table. These actions are also available from the XML > Grid Editing
menu and from the grid shortcut menu.
To add a row:
1.
Select the row next to which you want to insert a new row.
2.
Click the Insert Row Before ( ) or Insert Row After ( ) button to add the new row
to the table. These actions are also available from the XML > Grid Editing menu and
from the grid shortcut menu.
The row is added to the table.
To delete a row:
1.
2.
Click Delete ( ). This action is also available from the XML > Grid Editing menu
and from the grid shortcut menu.
The row is deleted from the table.
169
Selecting a Column
Column operations can be performed when you select any cell in a column. When a cell
(and, therefore, its column) is selected, it is highlighted with a yellow outline. As shown
in Figure 120, the <title> column is selected the cell containing Java Message Service
is the one that is highlighted.
Adding Columns
You can add two types of columns to tables in the Grid tab attribute columns and element
columns. The procedure for adding both types of columns is the same. When you add a
column, it is inserted immediately after the last column of its type. You can move columns
after you create them.
170
2.
Click Add Attribute Column ( ) or Add Element Column ( ). These actions are
also available from the XML > Grid Editing menu and from the grid shortcut menu.
The column is added to the table.
3.
If you want, move the column to a new location in the row. See Reordering
Columns on page 171.
Deleting Columns
To delete a column:
1.
2.
Click Delete Column ( ). This action is also available from the XML > Grid Editing
menu and from the grid shortcut menu.
The column is deleted from the table.
Reordering Columns
You can reorder columns in the grid by dragging them to the position you desire.
To reorder a column:
1.
2.
4.
171
Renaming Columns
You can rename columns in the grid. This has the effect of renaming the corresponding
attribute or element name in the underlying XML document.
Note You cannot rename the root element from the Grid tab.
To rename a column:
1.
2.
Click Rename Column ( ). This action is also available from the XML > Grid Editing
menu and from the column shortcut menu.
The column is renamed.
Changing a Value
You can change element and attribute values.
To change a value:
1.
3.
Press Enter.
A nested table is created as a child of the current element. The nested table shown in
Figure 124, myTable, was created as a child of the <book> element.
Nested tables are created with two default rows, which use the element name you provide
in the Row Element Name field of the Add Nested Table dialog box. Rows get a default
173
text value of Row n text, where n is an incrementing value starting with 1. You specify the
number of rows using the Number of rows field.
To add a nested table:
1.
2.
Click Add Nested Table ( ). This action is also available from the XML > Grid
Editing menu and from the grid shortcut menu.
The Add Nested Table dialog box appears.
3.
Optionally, specify the path to the root. If you leave this field blank, the nested table
is created as a child of the current element.
4.
5.
6.
Click OK.
The nested table is added to the document and appears in the grid.
2.
Click the Move Up ( ) or Move Down ( ) button to move the table to the desired
location. These actions are also available from the XML > Grid Editing menu and from
the grid shortcut menu.
Deleting a Table
To delete a table:
174
1.
2.
Click Delete ( ). This action is also available from the XML > Grid Editing menu
and from the grid shortcut menu.
The table is deleted from the document.
Sorting a Table
You can sort tables on any column in ascending or descending order.
To sort a table:
Tip
1.
Select a cell in the column on which you want to sort the table.
2.
Click the Sort Ascending ( ) or Sort Descending ( ) button to sort the table rows
in ascending or descending order, respectively. These actions are also available from
the XML > Grid Editing menu and from the grid shortcut menu.
You can also display sort options by right-clicking the column heading.
The table rows are sorted based on the order you select.
Note that when you use this feature, the entire table is copied column headings (element
and attribute names) are not distinguished from cell contents (element and attribute
values) in the spreadsheet.
175
2.
Select XML > Grid Editing > Copy as Tab-Delimited from the menu. This action is also
available from the grid shortcut menu.
Running the Diff Tool from the Command Line on page 204
176
Overview
Stylus Studios Diff tool lets you easily compare two or more versions of the same
document in the XML Diff Viewer (as shown in Figure 126), or the contents of two
folders (as shown in Figure 130).
Customizable color-coding lets you quickly determine how one document differs from
another green, for example, identifies objects (such as elements and attributes) that are
present in the target document, but which do not exist in the source document. When you
hover the pointer over symbols displayed in the side bars of the source and target
document windows, Stylus Studio displays a tool tip that indicates the specific nature of
the change.
This section covers the following topics:
177
right click on the XML Diff Viewer background and select the document you want to
edit from the short-cut menu of source and target documents displayed by Stylus Studio.
This feature is context-sensitive if you right-click on a node that has been removed, the
target document will not be listed, for example.
Comments
Text
178
Entities
Attributes
Processing instructions
You can also specify whether or not you want Stylus Studio to:
Ignore text formatting characters (new lines, carriage returns, and tabs)
See Modifying Default Diff Settings on page 200 to learn how to set these and other diff
options.
Folders Options for diffing XML documents do not affect how Stylus Studio diffs
folders. When diffing folders, Stylus Studio compares one folders contents with another.
See Diffing Folders on page 182for more information on this topic.
Figure 127. Performance Settings Let You Tune the Diffing Algorithm
179
You can
Select a tuning that optimizes the algorithm to provide the most economical set of
changes possible (Optimize change description). As described earlier, this
calculation, though it yields the best results, can be costly in terms of time and
processing resources.
Select a tuning that optimizes the algorithm to provide the set of changes in the
shortest time possible (Optimize calculation time).
Let Stylus Studio decide (Autodetect). By default, Stylus Studio tries to provide the
most economical set of changes possible, but if it determines that processing
resources are limited or that the calculation will take too much time, it reverts to the
algorithm tuning that is optimized for speed.
Handling Large Documents
The Optimize for large documents with few changes setting helps speed the diffing of
large (greater than 1MB) documents. This setting can be used in conjunction with any of
the algorithm tuning settings and is on by default.
On changes Certain types of changes to the diff configuration file require Stylus
Studio to recalculate the diff. These changes include:
180
If the On changes setting is on, Stylus Studio automatically runs the diff when any of
these changes occurs.
If files modified If you make and save changes to a source or target document, Stylus
Studio automatically runs the diff if this setting is on.
See Modifying Default Diff Settings on page 200to learn more about setting these and
other Diff options.
Background Color
Identifies
Light green
Light red
Light yellow
Light gray
181
You can change the background colors on the Presentation page of the Options dialog
box.
Combined Symbols
As described in Table 14, Default Colors Used for Diffing Files and Folders,, Stylus
Studio displays a turquoise block ( ) when a node that you have collapsed contains
changes. Sometimes, the node itself has changes. In this case, Stylus Studio combines two
symbols one indicating the change of a child within the collapsed node, and one to the
node itself. Consider the following illustration:
Here, the city node displays a combined symbol the turquoise box indicates that a
change exists within the collapsed node; the minus sign indicates that the city node is not
present in the source document. Expanding the city node makes the scope and nature of
the changes explicit:
the change.
Additional Symbols for Diffing Multiple Sources
Stylus Studio uses other symbols in the target document window when you diff multiple
source documents. See Symbols Used in the Target Document Window on page 196.
Diffing Folders
Stylus Studio allows you to diff two folders. As shown in Figure 130, the Diff Folders
dialog box displays the contents of each folder; symbols and colors, described in
182
Symbols and Background Colors on page 181, identify the types of changes in the
respective folders.
Splitter
How to Diff Documents from the Diff Folders Dialog Box on page 186
Features
The Diff Folders dialog box has several features that make it easy to diff folders and the
XML documents they contain:
A splitter lets you change the width of the source and target folder windows. This can
be especially useful if you are working with a folder that has nested directories.
A file type filter limits the display to files with a .xml extension; if you choose, you
can display (and diff) all file types, as shown in Figure 130.
An Abort button, shown here, appears at the bottom of the Diff Folders dialog box if
the operation you are performing (loading or diffing a directory with a large number
183
of files, for example) is taking more time than usual. Clicking the Abort button
cancels the operation.
Figure 131. Abort Button Lets You Cancel Long Load Operations
Tip
The Diff Files button allows you to perform a diff of XML documents in the source
and target folders. See How to Diff Documents from the Diff Folders Dialog Box
on page 186for more information on this topic.
Select Tools > Show Differences In > Folders from the Stylus Studio menu.
The Diff Folders dialog box appears.
184
3.
Expand the Desktop tree and navigate to the folder you want to use as the source
folder for the diff.
4.
Click Open.
The folder is displayed in the Source folder window of the Diff Folders dialog box.
5.
6.
Optionally, use the Show files of type drop-down list to filter the display to show only
those files of the type you specify. (By default, Stylus Studio shows XML files files
with a .xml extension.)
185
Notice that, even though the file names are different, Stylus Studio is able to infer that
authors_new.xml and authors_mods.xml are actually the same document.
Tip
If you select a document that cannot be diffed, you will not see the selection in the
opposite window.
2.
For more information on diffing documents, see Diffing a Pair of XML Documents on
page 193.
186
In split views (there is also a split view that shows documents in XML), source documents
are displayed on the left, the target document on the right. A splitter between the two
panes allows you to change the width of the source and target document panes by
dragging the splitter to the left and right.
187
188
Merged View
If you prefer, you can select the Merged View tab, which folds the nodes from the source
and target documents into a single window, as shown in Figure 134.
The merged view displays changed items in pairs the item from the target document
appears first, the item from the source document is shown second, as shown in Figure 135.
In this example, the line through the <au_lname> element in the source document,
Hennings, indicates that it has changed to White in the target document.
189
Show or ignore differences in document items such as text nodes and attributes
The following table identifies the individual tools and tells you where to find more
information.
Table 15. XML Diff Tool Bar Buttons
Tool Button
Description
Calculates the differences in the documents you have selected. This button is
active only when Stylus Studio detects the need to calculate differences. This
button is disabled if you have selected On changes and If files modified
settings. See Engine Settings on page 202.
Skips to the next (previous) diff in the currently selected document. You
must select a line in the document to enable these buttons.
190
Description
By default, Stylus Studio displays collapsed documents when the diff is run.
You can override this setting using the tool bar button, or you can change it
permanently on the Options. page. See Engine Settings on page 202.
By default, Stylus Studio collapses any unchanged blocks to simplify the
display. You can override this setting using the tool bar button, or you can
change it permanently on the Options. page. See Engine Settings on
page 202.
By default, Stylus Studio uses URIs to compare namespaces when diffing
documents. You can override this setting using the tool bar button, or you can
change it permanently on the Options. page. See Engine Settings on
page 202.
Note that changing this setting requires documents to be diffed again.
By default, Stylus Studio expands entity references when diffing documents.
You can override this setting using the tool bar button, or you can change it
permanently on the Options. page. See Engine Settings on page 202.
Note that changing this setting requires documents to be diffed again.
By default, Stylus Studio considers text formatting characters (new lines,
carriage returns, tabs) when diffing documents. You can override this setting
using the tool bar button, or you can change it permanently on the Options.
page. See Engine Settings on page 202.
By default Stylus Studio shows differences in comments. You can override
this setting using the tool bar button, or you can change it permanently on the
Options. page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of
comment differences.
By default Stylus Studio shows differences in text blocks. You can override
this setting using the tool bar button, or you can change it permanently on the
Options. page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of text
block differences.
191
Description
By default Stylus Studio shows differences in attributes. You can override
this setting using the tool bar button, or you can change it permanently on the
Options. page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of
attribute differences.
By default Stylus Studio shows differences in processing instructions. You
can override this setting using the tool bar button, or you can change it
permanently on the Options page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of
processing instruction differences.
By default Stylus Studio shows differences in entities. You can override this
setting using the tool bar button, or you can change it permanently on the
Options page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of
entity differences.
By default Stylus Studio shows differences in entity references. You can
override this setting using the tool bar button, or you can change it
permanently on the Options page. See Engine Settings on page 202.
Note that this feature affects only the display, and not the calculation, of
entity differences.
Allows you to change the font of documents displayed in the XML Diff
Viewer.
192
Add/Remove document buttons. When you click the add or set document button,
Stylus Studio displays the Open dialog box. The add button for source documents
displays a green plus sign on it (
) to alert you to the fact that you can add multiple
source documents when diffing XML documents. You can specify only a single target
document, however.
You use the remove button, the folder with the red minus sign on it (
), to remove
the current source document from the XML diff calculation.
If Stylus Studio determines that the load or diff operation for a given XML document
will take more than a moment, it displays a message and an Abort button at the
bottom of the XML Diff Viewer window. You can click the Abort button to terminate
the operation at any time. The message and the button are removed from the XML
Diff Viewer window once the operation is complete or cancelled.
Tip
Drop-down list. You use the drop-down list to change the current document in the
XML Diff Viewer. When you change the current doc in a multi-document diff, the
target document display specifically, the symbols and colors used to identify
documents typically changes, as well. See Symbols Used in the Target Document
Window on page 196 for more information.
193
Select Tools > Options > Show Differences > Files from the Stylus Studio menu.
Stylus Studio displays the XML Diff Viewer.
2.
You can drag and drop a file into the entry field to load the document in the XML Diff
Viewer.
Tip
194
3.
Navigate to the document you want to load in the XML Diff Viewer.
4.
Click Open.
5.
Repeat Step 2 through Step 4 for the target document, using the set button for the
target document window (
).
By default, Stylus Studio runs the diff calculation automatically when you select the
target document. If the default On changes setting has changed, you need to run the
diff calculation manually by clicking the Calculate diff button (
).
Document Focus
Diffing multiple XML documents is much the same as diffing a pair of documents you
specify the source documents (one at a time), a target document, and Stylus Studio
calculates the diff.
Note When you diff multiple source documents against the target, Stylus Studio considers the
target document to be the baseline, and the XML Diff Viewer shows how the source
documents vary from the target.
195
ge
t.x
m
l
ta
r
so
ur
ce
3.
xm
l
so
ur
ce
2.
xm
l
so
ur
ce
1.
xm
When you diff multiple documents, however, only one source document can have focus
at a time. Consider the following illustration, which shows three source documents
(source1.xml, source2.xml, and source3.xml) and a target document (target.xml).
In this example, the source1.xml document currently has focus. You set the focus on a
given source document by selecting that document from the drop-down list at the top of
the source document window.
When a source document has focus:
Diffs are displayed for that document only, even if you have selected the Merged View
tab for display.
196
current source document differs from changes to the same node in other source
documents.
Change relative
to current target
and current source
Change in current source
relative to other source
documents
As shown in Figure 138, symbols in the column closest to the document tree identify the
changes relative to the currently selected source. Here, the edit symbol ( ) indicates that
the value in the target document, White, differs from that in the currently selected source
(which happens to be Black in this example).
The first column of symbols characterize changes in the currently selected source relative
to other source documents. Here, for example, the red exclamation point ( ) indicates
that there are conflicting modifications in other source documents that is, other source
documents contain a value other than Black. As shown in Figure 139, when you click on
a symbol in the first column, Stylus Studio displays
Clicking on a document in this menu changes the current focus to that source document,
allowing you to easily navigate to the same node in a different document.
197
The additional symbols used by Stylus Studio when diffing multiple documents are
described in Table 16.
Table 16. Symbols Used to Specify Changes in Source Documents
Symbol
Description
Meaning
Yellow circle
Red exclamation
point
Yellow diamond
so
ur
ce
1.
xm
Consider the example in Figure 140, which illustrates diffing three documents. In this
example, the node in question is circled in red.
l
ge
t.x
m
<abc>
so
ur
ce
3.
xm
l
<xyz>
ta
r
so
ur
ce
2.
xm
<abc>
<123>
Notice that:
source1.xml currently
has focus.
source1.xml and the target document node have the same value (<abc>)
The node in question varies in both of the remaining source documents (it is <abc> in
one and <abc> in the other).
Table 17 shows the symbols that might appear based on changing values to the node in
question. The example illustrated in Figure 140 is shown in the first row. As values in the
source documents change, Stylus Studio changes the diff symbol accordingly.
Table 17. Symbols Used to Specify Changes in Source Documents
Symbol
target.xml
source1.xml
source2.xml
source3.xml
<abc>
<abc>
<xyz>
<123>
<abc>
<xyz>
<jkl>
<mno>
<abc>
<xyz>
<xyz>
<xyz>
<abc>
<xyz>
<abc>
<abc>
Note Changing the target-source pairing, that is, changing the current source document, affects
Select Tools > Options > Show Differences > Files from the Stylus Studio menu.
Stylus Studio displays the XML Diff Viewer.
2.
You can drag and drop a file into the entry field to load the document in the XML Diff
Viewer.
Tip
3.
Navigate to the document you want to load in the XML Diff Viewer.
4.
Click Open.
5.
199
Repeat Step 2 through Step 4 for the target document, using the set button for the
target document window (
).
By default, Stylus Studio runs the diff calculation automatically when you select the
target document. If the default On changes setting has changed, you need to run the
diff calculation manually by clicking the Calculate diff button (
).
200
Settings on the Engine page are reflected in the Diff editor tool bar, and in the XML Diff
menu, shown here.
2.
If necessary, expand the tree for Module Settings > XML Diff.
201
Click the page that contains the settings you want to modify.
4.
To save a changed setting, click OK. Click Cancel to revert to close the dialog box and
revert to the previous settings.
Engine Settings
This section describes the settings that affect the behavior and performance of the Diff
engine.
General
The fields in the General group box affect the initial display of diffed documents and the
conditions, if any, under which Stylus Studio runs the diff automatically.
Automatically expand all diffs By default, Stylus Studio collapses the display of the
diffed documents. If you select this option, all nodes containing diffs are expanded
when the diff is run.
Collapse unchanged blocks By default, Stylus Studio collapses any block that does
not contain any changes to save space in the XML Diff Viewer window. These blocks
are displayed as <unchanged> in the document tree. You might prefer to have the entire
document structure visible, to provide context for changed nodes, for example.
Autorun diff By default, Stylus Studio runs the diff operation if you make a change
to one of the settings on the Engine page of the Options dialog box. You can also
specify that Stylus Studio run the diff operation when the source or target documents
change. If you select If files modified, Stylus Studio runs the diff operation when you
save a source or target file. If neither of these options is selected, you must run the diff
manually. See When Does the Diff Run? on page 180 for more information on this
topic.
Engine Options
The fields in the Engine Options group box affect how Stylus Studio diffs source and
target documents.
Use URI to compare namespaces Controls whether or not URIs are used to
compare namespaces in source and target documents.
Expand entity references Controls whether or not entity references, which in some
cases can include files external to the source or target document, are expanded by the
Stylus Studio diff engine for purposes of comparing one block with another.
202
characters (new line, carriage return, and tab) are ignored when comparing source and
target documents. This option is off by default.
Show differences in Provides granular control of what items in XML documents
are diffed. There are separate settings for comments, text, entities, attributes, and
processing instructions.
Performance
Diffing large, numerous, or complex documents can be time-consuming. Stylus Studio
provides controls that let you choose algorithm tunings that have been optimized for
change description or calculation time.
Autodetect Stylus Studio determines which algorithm tuning to use based on the
number, content, complexity, and size of the source and target documents. Stylus
Studio first tries to use the tuning that is optimized for change description; if it
determines that processing resources are limited, it reverts to the algorithm tuning
optimized for speed. This setting is on by default.
Optimize calculation time Provides the set of changes in the shortest time possible.
Optimize for large documents with few changes Helps speed the diffing of large
(greater than 1MB) documents by folding similar blocks before comparing nodes.
This setting can be used in conjunction with any of the algorithm tuning settings and
is on by default.
Tip The default setting, Autodetect and Optimize for large documents with few changes,
yields the best results when time and processing resources are not considerations.
203
Presentation Options
Presentation options allow you to modify the settings for the background colors Stylus
Studio uses to identify the types of changes detected in diffed documents and folders
Figure 143. You Can Change Colors Used to Identify Document Changes
Added items
Removed items (that is, items that are present in the target, but are not present in the
source, for example)
Changed items (the same element or attribute, but a different name, for example)
204
Restrictions
The following restrictions exist for using StylusDiff.exe:
Usage
The StylusDiff.exe utility has the following usage:
StylusDiff -source <sourceURI> -target <targetURI>
[-expandPrefixes/collapsePrefixes] [-expandERs/collapseERs]
[-comments/nocomments] [-attributes/noattributes] [-text/notext] [-pi/nopi]
[-er/noer] [-entities/noentities] [-formatting/noformatting] [-fold/nofold]
[-auto/best/fast]
Table 18 describes the usage for the StylusDiff command. For a complete description of
these and other options that affect the XML Diff engine, see Engine Settings on
page 202.
Table 18. StylusDiff Command Line Parameters
Parameter
Description
-source <sourceURI>
The path of the XML document you want to use as the source
document in the diff. Required.
-target <targetURI>
The path of the XML document you want to use as the target
document in the diff. Required.
-output <outputURI>
-expandPrefixes
-collapsePrefixes
Whether you want the XML Diff engine to use the URI
(-expandPrefixes) or ignore the URI (-collapsePrefixes)
when comparing namespaces. The default is
-collapsePrefixes.
-expandERs
-collapseERs
205
206
Parameter
Description
-comments
-noComments
-attributes
-noAttributes
-text
-noText
-pi
-noPI
-er
-noER
-entities
-noEntities
-formatting
-noFormatting
-fold
-noFold
Whether you want the XML Diff engine to fold similar blocks
before diffing (-foldUnchangedBlocks) or to expand and diff
nodes (-diffUnchangedBlocks). The default is
-foldUnchangedBlocks.
-auto
-best
-fast
To define an internal DTD, specify it in the XML editor Text tab or Schema tab.
To have Stylus Studio generate a schema, in the XML editor, click the Schema tab. If
the XML document has some contents, Stylus Studio prompts you to indicate whether
you want Stylus Studio to generate a schema from the contents. See Having Stylus
Studio Generate a Schema on page 208.
This section discusses the following topics:
Open the XML document you want to associate with a schema. See Opening Files
in Stylus Studio on page 92.
2.
From the Stylus Studio menu bar, select XML > Associate XML with Schema.
3.
In the Open dialog box that appears, navigate to and select the schema you want to
associate.
4.
Click Open. The selected schema is now associated with the document.
To associate an XML document with an XML Schema, the XML document must contain
a root element.
207
After you associate a schema with a document, you can view a tree representation of the
schema in the XML editor window. Click the Schema tab. See Updating a Documents
Schema on page 209.
messages about invalid documents are generated by the Xerces XML Parser. Stylus
Studio has no control over the contents of these messages. If you have trouble
understanding such a message, try searching the W3C XML Schema Recommendation
for the main phrase in the error message.
208
209
2.
Select Edit > Make Canonical XML from the Stylus Studio menu.
Alternative: Click the Make Canonical XML button (
) on the tool bar.
The XML document is converted to its canonical form.
210
1.
2.
or press Ctrl+P.
Ensure that the window that contains your XML document is the active window.
2.
From the Stylus Studio menu bar, select File > Save.
Alternatives: Press Ctrl+S or click Save
in the Stylus Studio tool bar.
Save modified documents every few minutes. This option is off by default, and has a
default setting of 10 minutes.
211
From the File Explorer window, by double-clicking the file name or selecting Open
or Open With from the files shortcut menu, for example
From the Project window, by selecting the file and then selecting either
Open Latest Backup from the files shortcut menu (right-click to display), or
Project > Open Documents Latest Backup from the Stylus Studio menu
212
Chapter 3
DataDirect XML Converters and custom XML conversions are available only
in Stylus Studio XML Enterprise Suite.
Stylus Studio uses DataDirect XML Converters to convert incoming streams of data
from native formats to outgoing streams of XML, and vice-versa. XML Converters
support standard file formats, including EDI, CSV, binary, and many others. XML
Converters also support the conversion of custom or proprietary formats that you specify
using a custom XML conversion definition.
This chapter describes how to use DataDirect XML Converters to convert standard and
proprietary files to XML in Stylus Studio, how to create your own custom XML
conversion definitions, and how to use files you convert on-the-fly elsewhere in Stylus
Studio as a source for XQuery and XSLT design, for example.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the Custom XML
Conversions module video.
You can read about other video demonstrations for the custom XML conversion definition
module here: http://www.stylusstudio.com/learn_convert_to_xml.html#converttoxml.
A complete list of all the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
This chapter covers the following topics:
213
Introduction
DataDirect XML Converters are high-performance Java and .NET components that
provide bi-directional, programmatic access to virtually any non-XML file including EDI,
flat files, and other legacy and proprietary formats. DataDirect XML Converters allow
developers to seamlessly stream any non-XML data as XML to industry-leading XML
processing components or to any application. They support StAX, SAX, XmlReader,
XmlWriter, DOM and I/O streaming interfaces, and can be embedded directly for
translation purposes, or as part of a chain of programs including XSLT and XQuery, or
even inside XML pipelines. DataDirect XML Converters maximize developer
productivity and provide a fast, scalable solution for converting between EDI and other
legacy formats and XML.
In the EDI to XML module (see Chapter 4 Converting EDI to XML for more
information on this module)
214
Introduction
Example
When you open or save a file in Stylus Studio, you have the option of converting that file
to or from XML using DataDirect XML Converters, as shown in the following
illustration:
In the Open dialog box and elsewhere in Stylus Studio, you can choose an XML
Converter for a
Specific file format (like EDI, CSV, dBase, or RTF, for example). See Types of XML
Converters on page 216 for a complete list of standard files supported by the XML
Converters.
Custom file definition created using the Stylus Studio Custom XML Conversion
Definition Editor. You can create custom XML conversion definitions to handle
proprietary file formats or extensions to formats already supported by DataDirect
XML Converters.
215
216
File Type
Description
Base-64
Binary
Comma-separated
value (CSV)
Custom
dBase
Data Interchange
Format (DIF)
DotD
Introduction
Table 19. Types of Files Handled by XML Converters
File Type
Description
EDI
JavaProps
Support for Java .properties file format, which are used for
program configuration, translation, and data storage.
JSON
Line
Pyx
RTF
SDI
Super Data Interchange (SDI) is another popular spreadsheetbased file format. There are also XML Converters for DIF and
SYLK.
SYLK
TAB
WinIni
WinWrite
217
Some XML Converters, for example, let you specify the line separator character, escape
character, root element name, and other aspects of the output format.
See Chapter 4, XML Converters Properties, in the DataDirect XML Converters
Users Guide and Reference for more information. Documentation for DataDirect XML
Converters is available:
In the \doc folder for DataDirect XML Converters where you installed Stylus Studio
\components\XML Converters for .NET\doc, for example
218
Introduction
2.
Navigate the file system that contains the file you want to open as XML. If necessary,
change the value in the Files of type field to filter the files that are displayed.
3.
5.
Select the XML Converters you want to use to convert your non-XML file to XML.
6.
Optionally, change the default values of the conversion properties to be used when
converting your file. See Chapter 4, XML Converters Properties, in the DataDirect
XML Converters Users Guide and Reference if you need help with this step:
http://www.datadirect.com/techres/xmlconvertersproddoc/index.ssp.
7.
Click OK.
Stylus Studio converts the file you specified in step 2 to XML using the DataDirect
XML Converters you selected in step 5. The file is displayed in a new instance of the
XML Editor.
219
Save back a previously converted file. Imagine using the CSV XML Converters to
convert bikes.txt to bikes.xml. You could modify the data in bikes.xml and save it
back using the CSV XML Converters. Stylus Studio could save the XML file as CSV
as long as you made no changes to the document structure (adding no new elements
or attributes, for example).
Use a Document Wizard to create an XML Schema from an EDI message type (ATIS,
Cargo-IMP, EANCOM, EDIFACT, Edig@s, HIPAA, HL7, NCPDP, PADIS,
TRADACOMS, or X12, for example), and use that XML Schema as the target
document in an XQuery or XSLT mapping. The XML document resulting from the
XQuery or XSLT transformation based on that XML Schema would conform to the
XML Schema expected by the EDI XML Converters.
For more information on Document Wizards, see Using Document Wizards to
Create XML on page 139. For more information about working with EDI files as
XML, see Working with EDI Conversions on page 276.
220
The Custom XML Conversion Definition Editor displays information read from the input
file, as well a number of other properties you can specify (such as whether or not you want
element names based on the files first row, for example) that are used when the file is
converted from its native format to XML.
221
You need to convert a file that does not conform to one of the standard file types
already supported by DataDirect XML Converters
You want to exercise more control over the XML that is output by the conversion
222
Stylus Studio makes are reflected in the Properties window in the Custom XML
Conversions Editor once the input file is opened.
Select File > New > Custom XML Conversion from the Stylus Studio menu.
The New Custom XML Conversion Definition dialog box appears.
Click the browse button ( ) and select the file you want to use to configure the
custom XML conversion definition settings. See Choosing an Input File on
page 222 if you need help with this step.
223
The Open dialog box appears. By default, the Files of Type field filter is set to display
.txt, .edi, .csv, .tab, .log, and .bin files.
The file you select should be representative of other files of this type that you wish to
convert to XML using the custom XML conversion definition you are creating.
Tip
3.
4.
Optionally, change the default file encoding and layout settings. See Specifying File
Settings on page 223 if you need help with this step.
5.
Click OK.
Stylus Studio displays the file you selected in the Custom XML Conversion Editor.
6.
Examine the file and its properties as it was read into the Custom XML Conversion
Editor by Stylus Studio.
7.
Modify the file layout, its regions, and its fields as needed. See Working with
Regions on page 238 and Working with Fields on page 247 if you need help with
this step.
8.
Modify the properties that govern XML output as needed. See Controlling XML
Output on page 255 if you need help with this step.
9.
10.
Enter a name for the custom XML conversion definition and click Save.
11.
If the results are not what you expect, return to step 7 and to step 8. You might also
considering revisiting the input file, making fundamental changes there, and then
reloading it.
The steps in this process are described in greater detail in the following sections.
Tip Once you have created and saved a custom XML conversion definition, you can use it to
open other non-XML files of the same type, just as you would with any other DataDirect
XML Converter. See Using XML Converters to Open a Non-XML File as XML on
page 219 for more information.
224
The input file is displayed in a document pane; properties that both describe the existing
file (encoding and size, for example) and define the XML output that will be generated
when converting this file (root and field element names, and whether or not you want the
XML to be indented, for example) are displayed in the Properties window. The schema
pane shows a representation of the XML Schema that will be output for the converted file.
Finally, in addition to current row and column position, note that the status bar also shows
the Unicode value of the current character.
225
This section describes the main features of the Custom XML Conversion Editor,
including how it interacts with the XML Converters engine. This section covers the
following topics:
Document Pane
The document pane displays the input files layout, including spaces, field separators, and
control characters. The input files appearance in the document pane is determined, in
part, by its format.
This section covers the following topics:
226
Figure 150 shows how this character-separated input file appears in the Custom XML
Conversion Editors document pane. By default, Stylus Studio aligns columns and fills the
empty cells of the shorter rows with a light blue to aid readability:
You can remove these spaces from the display and view the file in its native format by
clicking the Align Fields button ( ) on the tool bar, or by selecting
CustomXMLConversion > Align Fields on the menu. This results in the layout shown in
Figure 151.
Fixed-width files are displayed in a slightly different fashion. Consider this fixed-width
input file:
Deep-sea octopus
Bathypolypus arcticus http://www.dal.ca/~ceph/TCP/barctic.html
Blue-ringed octopus
Hapalochlaena lunulatahttp://www.dal.ca/~ceph/TCP/lunulata.html
Caribbean reef octopusOctopus briareus
http://www.dal.ca/~ceph/TCP/obriar.html
Giant octopus
Octopus dofleini
http://www.dal.ca/~ceph/TCP/giant.html
Common octopus
Octopus vulgaris
http://www.dal.ca/~ceph/TCP/Octopusvulgaris.html
Red octopus
Octopus rubescens
http://www.dal.ca/~ceph/TCP/redocto.html
Octopus Salutii
Octopus salutii
http://www.dal.ca/~ceph/TCP/Osalutii.html
Octopus Macropus
Octopus macropus
http://www.dal.ca/~ceph/TCP/Omacropus.html
227
In a fixed-width file, the empty cells represent actual values (spaces) in the input file. In
the second row of this input file, for example, there are three spaces between the first and
second columns:
Delimiting characters, like the comma used in the example in Figure 150, are
displayed with a dark blue background. For files that include sub-fields or arrays (like
EDI, for example), the sub-field separator character is shown in a different shade of
blue. Sub-sub-fields delimiting characters are shown in a shade of purple.
Control characters (line feeds and carriage returns, for example) are shown using their
abbreviated ASCII value. A carriage return (0x0D) line feed (0x0A) is shown as
,
for example. ASCII abbreviations are aligned vertically, to preserve space, as shown
in this representation of the ASCII value for tab (0x09): .
Stylus Studio understands all Unicode characters,. When editing Line-Oriented
Region and Field Name values in the Properties window, you can enter mnemonic
values for the C1 and C0 control characters in the following ranges:
Characters that are discarded from output (like line terminators such as CR and LF
and comment lines) are displayed against a gray background.
228
You can hide control characters by clicking the Toggle Control Characters button ( )
on the tool bar, or by selecting ConvertToXML > Toggle Control Characters from the
menu.
Field Names
User-defined field names values that Stylus Studio uses to create the element names in
converted XML are displayed in green, as shown here:
Figure 154. Blue Arrow Indicates Field Names Taken from the File
See Naming Fields on page 247 to learn more about naming fields for XML output by
custom XML conversion definitions.
229
To highlight matching rows, click the Highlight Matching Rows button ( ) on the tool
bar, or select CustomXMLConversion > Highlight Matching Rows from the menu.
230
Matching rows are displayed in light yellow, with a green check in the panes margin. A
red X identifies rows that do not match the current pattern. Gray squares identify rows that
match a pattern other than the pattern defined for the row that currently has focus. See
Specifying Multiple Match Patterns on page 259 for more information on this feature.
Tip Only rows that match the same pattern that the current row matches are highlighted. Also,
tooltips appear when you hover the pointer over the match symbols. These tooltips
display the pattern that the row matches.
See Pattern Matching on page 257 to learn more about using regular expressions to
define match patterns.
Grid Lines
The document pane displays both vertical and horizontal lines by default; you can
hide/show them independently. In the example shown in Figure 157, horizontal lines are
hidden from the display:
Figure 157. You Can Hide Horizontal and Vertical Grid Lines
To hide horizontal and vertical grid lines, click the Toggle Horizontal Grid Lines ( )
and/or Toggle Vertical Grid Lines ( ) buttons on the tool bar, or select ConvertToXML >
Toggle Horizontal Grid Lines and/or Toggle Vertical Grid Lines from the menu.
Tip Hiding horizontal lines while displaying the ruler is an effective way to quickly scan
columns.
Fonts
By default, the input document is displayed using the Courier New font in 12pt. You can
change the display font to suit your personal preference using the Edit > Change Font and
Edit > Font Size menus.
231
The directional arrows and Page Up, Page Down, Home, and End keys on your
keyboard
Your mouse (click on the character on which you want to place the cursor)
Using Go To
You use the Go To dialog box to jump to a specific location in the file you are using to
create your custom XML conversion definition. You can use it to move the cursor to a
specific
Region
232
Properties Window
The Properties window, like the one shown in Figure 159, displays information about the
input file, as well as settings that Stylus Studio will use convert files to XML.
Information read or inferred from the input file when it is first opened in the Custom
XML Conversion Editor. Examples include the file name, file size, and number of
characters that were read. Some values, such as the type of encoding, can be edited.
Informational fields that cannot be edited are identified with a blue circle: .
Values you want the XML Converters engine to use when converting this input file
and other files of this type to XML. Output properties include the root element name,
the namespace and namespace prefix, and the field element name. These fields are
identified with a green arrow over a document icon:
.
233
Input File read-only information read or inferred from the input file, and editable
properties that affect XML output. These properties affect the file as a whole when it
is converted to XML. Input file properties are identified by this icon:
.
XML Output URL properties that affect the XML document created by the custom
XML conversion definition, including the name you want to use for the root element,
and whether or not you want to indent the XML. Output URL properties are identified
by this icon:
.
Region Type read-only information inferred from the input file, and editable
properties that affect XML output. Examples include line terminating and escape
characters. These properties affect a contiguous portion of the file (that is, a given
line-oriented or fixed-width region) when it is converted to XML. Region properties
are identified by this icon: .
Row Element Name properties that affect which rows of the input file are output to
XML and how they are output, including the name you want to use for the row. Row
properties are identified with this icon:
.
Field Element Name read-only information read or inferred from the input file, and
editable properties that affect XML output. These properties affect only fields in a
given region of the file when it is converted to XML. Field properties are identified
by this icon:
.
Note Informational properties, that is, properties that do not affect XML output, are displayed
with the following icon: . These properties are displayed when you click the Toggle
Informational Properties button.
234
Schema Pane
The schema pane displays a representation of the XML Schema for the XML document
that will be output when the input file is converted to XML.
You can double-click on a row element to display the Set Node and Match Pattern dialog
box, shown in Figure 161. This functionality provides an alternative to editing the row
name and specifying a match pattern in the Properties window. (To learn more about
patterns and how to use them in your custom XML conversion definitions, see Pattern
Matching on page 257.)
You can also edit schema node names directly in the schema pane just click twice to
place the node name in edit mode.
See Rows on page 237 to learn more about specifying conversion properties for rows.
235
Regions
A region is the largest organizational component in an input file. Regions are interpreted
by Stylus Studio when the input file is first read into the Custom XML Conversion Editor.
You can use the editor to define your own, as well.
An input file can contain one or more regions; every input file has at least one region that
starts at offset 0. Multiple regions are common in binary files, which often contain a fixedsize header and then one or more records containing the actual data. Regions are fixed in
size and cannot repeat.
In the Custom XML Conversion Editor, regions are numbered, starting with 1, followed
by the row number. For example, in an input file with two regions, you might see rows
labeled as follows: 1:1, 2:1, 2:2, 2:3, and so on, as shown here:
236
Region Types
Regions can be fixed-width or line-oriented. You can also set the Region Type property
to No-output. Regions that are marked as No-output are grayed out in the Custom XML
Conversion Editor, and they are not converted to XML.
Managing Regions
Stylus Studio provides tools that let you create new regions, and join one region with
another. You can also change a regions type, define different line terminators across
regions, and mark a region so that it is excluded from output. For information on these and
other topics, see Working with Regions on page 238.
Rows
A row is equivalent to a record, line, or tuple in the input file; a row is made up of fields.
An example of a row is an employee record; examples of fields in an employee record
include employee_id, last_name, first_name, and so on.
Every region can have one or more rows. (A region cannot be empty.) In addition, a region
can have multiple row types. Rows are selected for conversion to XML based on the
match patterns expressed in the Match Pattern field of the Properties window. See
Omitting Regions and Fields, and Rows on page 256 for more information.
Rows in a fixed-width region have the same width as the region itself; fields within each
row are defined by a fixed number of columns. Stylus Studio uses a default value of 80
characters for row length in fixed-width regions, but you can adjust this as required from
within the Custom XML Conversion Editor. See Adjusting Fixed-Width Regions on
page 241 for more information.
In a fixed-width region, you can
237
Fields
A field is one or more columns in a row that contains data. Each different row type has its
own independent set of fields. An example of a field in an employee record is
employee_id.
Stylus Studio supports many data types (string, Boolean, number, date, time, and so on)
and recognizes many different input formats (like different date formats, for example).
Properties vary based on data type the Base property, for example, is applicable only to
Number data types.
You can define your own fields in fixed-width input files. See Defining Fields on
page 250 for more information.
238
Regions with CR/LF control characters are interpreted as line-oriented regions. There
might be occasions, however, when you want to change the region type from line-oriented
to fixed-width, or vice versa. This section describes the tools you can use to change a
region from one type to another.
Consider the following file fixed-width file:
Make
BMW
Kawasaki
Ducati
MotoGuzzi
BMW
Ducati
Aprilia
Model
R1150RS
GPz1100
ST2
LeMans
R1150R
Monster
Futura
Year
2004
1996
1997
2001
2002
2000
2001
Mileage
14274
60234
24000
12393
17439
15682
17320
It is a simple .txt file with fields (Make, Model, and so on) that have been created using
spaces. Each new row was created using the Enter key in the text editor, resulting in
CR/LF control characters at the end of each line that cause Stylus Studio to interpret the
file as a single line-oriented region, like this:
For display purposes, we can remove the spaces Stylus Studio has inserted for readability
(the cells with the light blue shading) by clicking the Align Fields ( ) button. This
239
results in a display that resembles the source (Figure 164), but Stylus Studio still
considers the region to be line-oriented.
When you convert a line-oriented region to a fixed-width region, Stylus Studio removes
spaces it added for readability and depicts only the spaces in the original input file used
to create the fields and the field values themselves, as show in Figure 165.
By default, Stylus Studio displays fixed-width files using an 80-character row. This
accounts for the input files appearance when it is first displayed as a fixed-width file if
you scan the document, you can see that all of the files original information, including
the CR/LF control characters has been retained, but that the formatting differs the
original input file had eight rows; now it has four rows of 80 characters.
Tip You can adjust the width of fixed-width regions. See Adjusting Fixed-Width Regions
on page 241.
240
2.
3.
If you have converted a line-oriented region to a fixed-width region, adjust the row
length as needed. See Adjusting Fixed-Width Regions on page 241.
There are several ways to specify the row length for a fixed-width region:
Using the Row Length property simply change the default value, 80, to the value
that is appropriate for the current region and press Enter.
Dragging the document pane to the left or right move the pointer to the right border
of the document pane. When it changes shape, press and hold mouse button 1 and
drag the right border of the grid until the input files fields are aligned.
Holding the Shift key and pressing the right arrow (to add width) or the left arrow (to
decrease width).
241
Each of these methods lets you explicitly set the row length. Alternatively, you can specify
a Line Terminator character manually, as shown in Figure 167.
Specifying a Line Terminator character means that the rows in the region can be of
variable length, based on the where the specified Line Terminator character occurs in the
record.
Tip When you specify a Line Terminator character for a fixed-width region, the value shown
in the Row Length property represents the value of the longest row in the region.
Example
After converting the line-oriented region shown in Figure 166 to fixed-width, it looks like
this:
242
Figure 166 shows the same fixed-width file after it has been resized by dragging the
document pane.
Defining a Region
When you define a region in an input file, Stylus Studio splits the region at the current
cursor location. The new region starts with the character on which the cursor resided when
the region was defined, but it can be of either type fixed-width or line-oriented
regardless of the type of the original region.
Consider the following input file:
# Bike Inventory Overview 2004-10-01 09:00:07EDT
Make,Model,Year,Mileage
BMW,R1150RS,2004,14274
Kawasaki,GPz1100,1996,60234
Ducati,ST2,1997,24000
Moto Guzzi,LeMans,2001,12393
BMW,R1150R,2002,17439
Ducati,Monster,2000,15682
Aprilia,Futura,2001,17320
243
By default, Stylus Studio reads this as a file with a single region. You might decide you
want your XML to distinguish headers from actual records and treat the two accordingly
(not generating headers as XML, for example).
When you define a new region, the Custom XML Conversion Editor renumbers all the
rows, using a region:row number format. In addition, each region is displayed with its own
field name row, which is displayed in light green with the default field element name,
field, as shown in Figure 170.
Field and row values are independent across regions. For example, the <row> element
might be <reg1>, <reg2>, and so on for each of the regions in an input file.
To define a region:
244
1.
Place the cursor in the document pane on the character with which you want to start
the new region.
2.
Click the Start New Region Here ( ) button, or select CustomXMLConversion >
Start New Region Here from the Stylus Studio menu.
Choose the type of region you want to create (line-oriented, fixed-width, or nooutput).
4.
Choose where you want the new region to start (at the current row, or at a specific
number of bytes from the start of the file).
If the .conv file you are creating will be used with different input files, it is possible
that the line lengths could vary from file to file, changing the byte offset. Consider
using the row setting (the default) for the Begin New Region property in this case.
Tip
5.
Click OK.
245
Joining Regions
You can join regions that you define as well as regions that Stylus Studio interpreted when
it first read the input file. You can join the current region to either adjacent region the
previous region, or the next region.
The region type after the join operation depends on whether you are joining with the
previous region or the next region.The region you are joining assumes the type of the
region to which it is being joined.
Table 20. Region Type After Joining Regions
Region Joined With
Next
Previous
To join a region:
1.
Place the cursor anywhere in the region you want to join with another region.
2.
Click the Join with Previous Region ( ) or Join with Next Region ( ) button.
These actions are also accessible from the CustomXMLConversion menu and the
shortcut menu in the Custom XML Conversion Editor.
Stylus Studio joins the region you specified in step 1with the adjacent region.
246
Naming Fields
Every field in an input file including fields in the same region and row can have its
own field element name. All field element names (<field> is the default) include the
namespace prefix in the XML output if one was specified.
Field names are determined by two properties Element Name Source in the Region
Type properties, and Field Element Name, as shown in Figure 172.
The Element Name Source indicates the origin of the field name used in the XML output
when converting the input file. The Field Element Name property specifies the actual
value used to name the <field> element.
247
User-Supplied Specifies that you will supply names for the <field> element. You
can do this by editing the Field Element Name property, or by double-clicking the
field element name in the document pane to edit the field name directly in the
document pane.
The default value of the Field Element Name property is field. If you use other values
for the Element Name Source property, Stylus Studio provides the values for the Field
Element Name property.
User-Supplied is the default setting for the Element Name Source property.
From First Row You can use this setting to take <field> element names from the
first row in the region. If you have used the Rows to Skip property to skip rows in a
region, the first available region is used to supply the <field> element names.
Consider the following input file:
Make:Model:Year
BMW:R1150RS:2004
MZ:Scorpion:1995
Ducati:ST2:1997
If you set Element Name Source to From First Row, the XML output uses Make,
Model, and Year for the <field> element names, as shown here:
<?xml version="1.0" encoding="utf-8"?>
<root>
<row>
<Make>BMW</Make>
<Model>R1150RS</Model>
<Year>2004</Year>
</row>
<row>
<Make>MZ</Make>
<Model>Scorpion</Model>
<Year>1995</Year>
</row>
<row>
<Make>Ducati</Make>
<Model>ST2</Model>
<Year>1997</Year>
</row>
</root>
You can specify any row as the source for field names using the Get Field Names from
This Row from the rows shortcut menu.
248
WS-EDI Standard This setting allows rows and fields to be named based on the WS-
In addition, preceding rows in that region, if any, are grayed out, and the value of the Rows
to Skip field in the Region Type properties changes to reflect this.
In the event that the first row has fewer names than there are fields in one or more
subsequent lines in the file, Stylus Studio names the extra fields <fieldn>, where n is the
field number relative to other fields in the row. Also, if the values in the row are not valid
XML identifiers, they are converted using the following rules:
SQL/XML rules are used, except that underscores (_) are not converted to _x005F_
symbols
Beyond these exceptions, strict rules are used. See section 9.1 (page 91) of
http://www.sqlx.org/SQL-XML-documents/5FCD-14-XML-2004-07.pdf.
Display the Properties window if it is not already displayed (click View > Properties
on the Stylus Studio menu).
2.
3.
Type the new name in the Field Element Name property and press Enter.
249
Alternative:
1.
Figure 174. You Can Edit the Field Name Directly in the Document Pane
2.
Display the Properties window if it is not already displayed (click View > Properties
on the Stylus Studio menu).
2.
Select the field name source you want to use from the Element Name Source dropdown list.
3.
Press Enter.
Defining Fields
You can define fields in any region in a fixed-width input file, as shown in Figure 175.
Once you have defined a field, you can change its size by simply dragging it to any column
in the grid.
Each field you define is treated as a separate element in the XML output by the custom
XML conversion definition. The input file shown in Figure 175, for example, would result
250
in XML with two <field> elements, one consisting of the make of motorcycle, and one
consisting of the model, year, and mileage. You can use the field feature to exercise
control over the XML defining separate fields for make, model, year, and mileage, for
example.
Consider the following input file:
Make
BMW
Kawasaki
Ducati
MotoGuzzi
BMW
Ducati
Aprilia
Model
R1150RS
GPz1100
ST2
LeMans
R1150R
Monster
Futura
Year
2004
1996
1997
2001
2002
2000
2001
Mileage
14274
60234
24000
12393
17439
15682
17320
By default, each row is considered to have a single field, containing Make, Model, Year, and
resulting in XML output like this:
Mileage,
Mileage
</field>
</row>
<row>
<field>BMW
14274
R1150RS
2004
</field>
</row>
...
251
If you specify fields for Model, Year, and Mileage, the XML output by the custom XML
conversion definition looks like this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<row>
<field>Make</field>
<field>Model</field>
<field>Year</field>
<field>Mileage
</field>
</row>
<row>
<field>BMW</field>
<field>R1150RS</field>
<field>2004</field>
<field>14274
</field>
</row>
...
Neither approach is always correct, but this feature gives you the ability to define the type
of XML output that is appropriate for your use.
Tip Of course, in this example, the next logical step might be to use the first row (Make, Model,
Year,
and Mileage) as the field names as described in Naming Fields on page 247.
To define a field:
1.
Place the cursor in the document pane on the character with which you want to start
the new field.
2.
Click the Begin Field in This Column ( ) button. This action is also accessible from
the CustomXMLConversion menu and the shortcut menu in the Custom XML
Conversion Editor.
Stylus Studio displays a thin orange line that identifies the start of the newly defined
field.
To remove a field:
The procedure for removing a field is the same as the procedure for defining one place
the cursor on any character adjacent to the field line you want to remove and click the
Begin Field in This Column (
) button.
252
Tip
Type the notes you want to associate with the field and click the OK button.
Tip If a field has a note defined for it, it is displayed in a tooltip which appears when you
hover the mouse pointer over the field in the Custom XML Conversion Editor.
253
Consider the following input file, which uses a semi-colon (;) to specify component fields:
Make;Model;Year;Color;Seat
BMW;R1150RS;2004;grey,metallic;black,vinyl
MZ;Scorpion;1995;green,clearcoat;black,vinyl
Ducati;ST2;1997;red,clearcoat;black,leather
Using the first row to supply the field names and default Component Element Name
(component), the custom XML conversion definition creates the following XML output
(first two elements shown for brevity):
<?xml version="1.0" encoding="utf-8"?>
<root>
<row>
<Make>BMW</Make>
<Model>R1150RS</Model>
<Year>2004</Year>
<Color>
<component>grey</component>
<component>metallic</component>
</Color>
<Seat>
<component>black</component>
<component>vinyl</component>
</Seat>
</row>
<row>
<Make>MZ</Make>
<Model>Scorpion</Model>
<Year>1995</Year>
<Color>
<component>green</component>
<component>clearcoat</component>
</Color>
<Seat>
<component>black</component>
<component>vinyl</component>
</Seat>
</row>
...
The <component> elements are created as subelements of the <Color> and <Seat> elements.
For line-oriented regions in files containing component fields, you can change the default
Field Component Separator property, and the Component Element Name and
Component Element Name properties, that is, the name you want to use for the
254
Root element The default for the <root> element is root. You can change the default
using the Root Element Name property.
Region element The default for the <region> element is region. You can change the
default using the Region Element Name property. Different regions can have different
names.
Namespace You can specify names for both the namespace prefix and the
namespace using the Namespace and Namespace Prefix properties, respectively. The
namespace prefix you specify is added to every element name.
Row element The default for the <row> element is row. You can change the default
using the Row Element Name property. Rows in different regions can have different
names.
Field element The default for the <field> element is field. You can change the
default using the Field Name property. Each field can have its own name. If your input
file defines subelements. you can use the Component Element Name and SubComponent Element Name properties to provide a name for the containing element.
Stylus Studio User Guide
255
Specifying Format
There are several ways to exercise control over the format of the XML document output
by a custom XML conversion definition.
Indenting By default, Stylus Studio indents the XML generated by a custom XML
conversion definition. You can remove indenting by changing the value of the Indent
XML? property to False.
XML Schema The XML Schema Document property allows you to specify the
XML Schema you want to associate with the XML output. There are also fields that
allow you to specify System and Public DTDs.
Omitting regions The Omit from Output property lets you omit an entire region from
XML output. (Regions with a Region Type of No-output are always omitted from
XML output.)
Omitting fields The Omit from Output property lets you omit a field from XML
output. You can omit a field
Comments You can filter rows using the Comment String property if the
beginning of a row matches the string you enter for this property, Stylus Studio
ignores the row when converting the input file to XML. You can also specify patterns
that rows must match in order for them to be converted to XML. See Pattern
Matching on page 257 for more information.
256
Pattern Matching
You can use regular expressions to specify match patterns for the rows in the input file.
Only those rows in the input file that match the pattern you specify are output to XML
when the file is converted. The simplest way to define a match pattern is to use the Match
Pattern property in the Row Element Name section of the Properties window.
Example
Consider the following input file:
Make,Model,Year,Mileage
BMW,R1150RS,2004,14274
Kawasaki,GPz1100,1996,60234
Ducati,ST2,1997,24000
Moto Guzzi,LeMans,2001,12393
BMW,R1150R,2002,17439
Ducati,Monster,2000,15682
Aprilia,Futura,2001,17320
If you specify a simple regular expression, say, ^B, for the Match Pattern property, Stylus
Studio displays the input file in the Custom XML Conversion Editor as shown in
Figure 177 green check marks identify the rows that match the pattern, and red Xs
identify the rows that do not. (You can also display matching rows in a contrasting color
by clicking the Highlight Matching Rows button. See Document Pane Display Features
on page 230 for more information about this feature.)
Note that the match pattern also appears as a new node in the schema pane. This new node,
the only one defined for the custom XML conversion definition at this point, uses the
default row element name (row) and the value of the expression.
257
Since the match pattern selects only those rows that begin with the letter B, the custom
XML conversion definition creates the following XML document when it is run against
the input file:
<?xml version="1.0" encoding="utf-8"?>
<root>
<row>
<Make>BMW</Make>
<Model>R1150RS</Model>
<Year>2004</Year>
<Mileage>14274</Mileage>
</row>
<row>
<Make>BMW</Make>
<Model>R1150R</Model>
<Year>2002</Year>
<Mileage>17439</Mileage>
</row>
See Working with Nodes on page 260 to learn about adding the row element
name/match pattern pairs that define them.
Matches
^ABC
^[Aa][Bb][Cc]
AAA
^(DEF | GHI)
XYZ$
XYZ\$
Go to http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html to
learn about the specific regular expression implementation supported in Stylus Studio. Go
258
Figure 178. Gray Squares Identify Rows That Match Other Patterns
259
Define a new node even one that does not match a row in the current input file. For
example, we could define a match pattern for Triumph motorcycles (<row> ^T) even
though there are no Triumph motorcycles in the input file.
Clone an existing node this allows you to copy an existing node and modify its
match pattern to create a new node.
Edit an existing node. (You can also do this in the Properties window, of course.)
When you open the dialog box, the Row Element Name and Match Pattern fields contain
default values that reflect the currently selected row in the document pane or node in the
schema pane.
Defining a New Node
To define a new node:
260
1.
2.
Select CustomXMLConversion > Add Node and Pattern from the Stylus Studio
menu.
Alternative: Select Add Node and Pattern from the document pane or schema pane
shortcut menu.
The Set Node and Pattern dialog box appears.
3.
Change the default values in the Row Element Name and Match Pattern fields.
4.
Click OK.
Cloning a Node
To clone a node:
1.
Select the node in the schema pane that you want to clone.
Alternative: Select the row in the document pane that is represented by a row element
name/match pattern pair you want to clone.
2.
Select CustomXMLConversion > Clone Node and Pattern from the Stylus Studio
menu.
Alternative: Select Clone Node and Pattern from the document pane or schema pane
shortcut menu.
The Set Node and Pattern dialog box appears.
3.
Change the default values in the Row Element Name and Match Pattern fields as
needed.
4.
Click OK.
Editing a Node
To edit a node:
1.
Select the node in the schema pane that you want to edit.
Alternative: Select the row in the document pane that is represented by a row element
name/match pattern pair you want to edit.
2.
Select CustomXMLConversion > Edit Node and Pattern from the Stylus Studio menu.
Alternative: Select Edit Node and Pattern from the document pane or schema pane
shortcut menu.
Alternative: Double-click the node.
The Set Node and Pattern dialog box appears.
3.
Change the default values in the Row Element Name and Match Pattern fields as
needed.
4.
Click OK.
Removing a Node
When you remove a node, you are deleting the row element name/match pattern pair from
the custom XML conversion you are defining.
261
Select the node in the schema pane that you want to remove.
Alternative: Select the row in the document pane that is represented by a row element
name/match pattern pair you want to remove.
2.
Select CustomXMLConversion > Remove Node and Pattern from the Stylus Studio
menu.
Alternative: Select Remove Node and Pattern from the document pane or schema
pane shortcut menu.
Alternative: Press the Delete key.
A warning message appears.
3.
For any Status fields in the input document with a value of, say, 100, Stylus Studio would
convert that value to Continue in the XML document it outputs; values of 202 would be
converted to Accepted; and so on.
262
Input file values that do not match a lookup are emitted in the XML document as-is,
allowing exceptional values to be decoded. For example, you might have a temperature
lookup list with these values for a <Temperature> field:
32 | Freeze
212 | Boil
You can define lookup lists only for fields in rows for which a match pattern (even a blank
match pattern, as is the default) exists. Finally, you can paste comma- and tab-delimited
text directly into the lookup list. This allows you to easily reuse existing lookup tables
without having to re-enter text.
To define a lookup list:
1.
2.
263
264
3.
4.
Function
OK
Cancel
Copy
Paste
Append
Insert
Delete
Note Copy, Paste, and Append use the system clipboard and insert at the current cursor
location. Any blank rows are discarded when you save the lookup list.
265
If you set the Key=Value Character property to =, Stylus Studio creates the following
XML document when you preview the custom XML conversion:
<?xml version="1.0" encoding="utf-8"?>
<root>
<row>
<field>Triumph Inventory</field>
<field>Year and Quantity</field>
</row>
<row>
<Yr2003>24</Yr2003>
</row>
<row>
<Yr2004>12</Yr2004>
</row>
<row>
<Yr2005>15</Yr2005>
</row>
</root>
266
Display the Open dialog box (select File > Open from the Stylus Studio menu, for
example).
Navigate to the directory that contains the file you want to open using the custom
XML conversion definition and select the file.
3.
Check the Open using XML Converter check box and click the Open button.
267
If you are using a custom XML conversion definition (.conv), select Custom XML
Conversions. Then, use the browse button in the Value field to locate the custom
XML conversion definition you want to use. Go to step 5.
Click OK.
The file is converted to XML and appears in the editor from which you displayed the
Open dialog box in step 1.
Tip You can use the same basic procedure, from the Save As dialog box, to save a file using
a custom XML conversion definition. See Saving an XML File in Another Format on
page 220.
268
The XML Converter you want to use EDI, CSV, dBase, custom XML conversion
definition (.conv file), and so on.
Values for any XML Converters properties (separator or escape characters, for
example) for which you do not want to use the default values. Options for custom
XML conversions are part of the custom XML conversion definition and are not
specified.
The instructions to the XML Converters engine from this instance of the converter:URI
are described the following table.
269
converter:csv
newline=lf
first=yes
file:///c:/StylusStudio/examples/three.txt
Properties that use default values (a comma is the default separator character for the CSV
XML Converter, for example) do not have to be specified in a converter:URI.
This converter uses myConverter.conv to convert the file inventory.txt to some format
(specified in the custom XML conversion definition when it was built using the Custom
XML Conversion Definition Editor in Stylus Studio). Note that individual configuration
properties are not specified they are part of the definition described in the .conv file.
Where:
name is the name of the DataDirect XML Converters or the .conv file name of a
custom XML conversion definition.
270
The names for XML Converters names are displayed in Stylus Studio; see Where
Converter URIs are Displayed in Stylus Studio on page 272. They are also described
in the DataDirect XML Converters documentation; see
http://www.datadirect.com/techres/xmlconvertersproddoc/index.ssp.
property_name is the name of a DataDirect XML Converters property. You need to
specify a property and its value only if you want to configure the converter to use
something other than the default value. You do not specify properties for custom
XML conversion definitions.
XML Converters properties are displayed in Stylus Studio; see Where Converter
URIs are Displayed in Stylus Studio on page 272. They are also described in the
DataDirect XML Converters documentation; see
http://www.datadirect.com/techres/xmlconvertersproddoc/index.ssp.
file URL is the URL of the file you want to convert.
271
You use the EDI to XML editor to create conversion files that you can save and reuse.
See Chapter 4 Converting EDI to XML for more information.
272
The URI field of the Select XML Converter dialog box displays the converter:URI for
the XML Converters or custom XML conversion definition you have selected.
Figure 186. Converter:URI Displayed in the Select XML Converter Dialog Box
Note that XML Converters name and properties used in the converter:URI vary from
the full names displayed in the Select XML Converter dialog box. In addition, note
that only properties whose default value you change in the Value field are displayed
in the URL field.
The Project window (select Show Full URL from the Project window shortcut menu)
displays the converter:URI used to create an XML document:
273
You can use any of these sources for the converter:URI strings you want to use in your
XQuery and XSLT code. See Using Stylus Studio to Build a Converter URI on
page 274 for more information.
Tip Converter URIs in the Select XML Converter dialog box are already escaped and can be
used as-is. Converter URIs taken from the Project window must be escaped manually
274
1.
Use the XML Converters to open a file as an XML document in Stylus Studio. See
Using XML Converters to Open a Non-XML File as XML on page 219or How to
Open a File Using a Custom XML Conversion Definition on page 266 if you need
help with this step.
2.
Before clicking OK to complete the conversion, copy the converter:URI in the URI
field of the Select XML Converter dialog box (see Figure 186).
3.
Click OK to complete the conversion. (You can click Cancel if you are peforming this
procedure just to obtain the converter:URI.)
4.
Use the XML Converters to open a file as an XML document in Stylus Studio. See
Using XML Converters to Open a Non-XML File as XML on page 219or How to
Open a File Using a Custom XML Conversion Definition on page 266 if you need
help with this step.
New documents are placed in the Other Documents folder in the Project window by
default.
Tip
2.
Open a new document in any Stylus Studio text editor (for example, File > New > XML
Document).
The purpose of this step is to provide an editor into which you can drag-and-drop the
the document you created in step 1 in order to display the associated converter:URI.
3.
Drag the document you created in step 1from the Project window and drop it into the
text editor you opened in step 2.
The complete URI appears in the text editor.
5.
Note: Escape characters as required for strings in Java programs. For example,
escape=\:quotes='" becomes escape=\\:quotes='\" (the single quote does not need to be
escaped).
Stylus Studio User Guide
275
ATIS
Cargo-IMP
EANCOM
EDIFACT
Edig@s
HL7
NCPDP
PADIS
TRADACOMS
X12
276
Visit http://www.datadirect.com/products/data-integration/datasources/edistandards/index.ssp to learn detailed information about version and message support for
all suppored EDI dialects.
A far easier way is to use the Stylus Studio EDI to XML module to create a SEF file. Using
graphical tools, the EDI to XML editor allows you to
Take advantage of the XML Converters repository of numerous EDI dialects and
versions
Customize an EDI dialect to suit your needs changing a segment from mandatory
to optional, for example
Process Overview
The process for converting a custom EDI message type includes the following steps:
1.
Create a SEF file (mycustomEDI.sef, for example) that describes how the custom EDI
message type differs from the EDI standard on which it is based its extensions or
restrictions, in other words. The purpose of this document is to teach the DataDirect
XML Converters engine about the differences between your custom EDI message
type and the EDI standard message type on which it is based.
277
Open the EDI file you want to convert to XML. Select File > Open, and then select
the Open Using XML Converter check box.
3.
Select the EDI XML Converter in the Select XML Converter dialog box.
4.
Specify the file URL for the SEF file (mycustomEDI.sef , for example) in the
Extension map file property. See Specifying the SEF File Location on page 278 if
you need help with this step.
278
For XML Converters for .NET set the registry key HKLM/Software/DataDirect/XML
Converters 5.0/ProductLocation
.NET
Java
Format (SEF). Use SEF files to describe the XML Schema for custom EDI message
types. For more information, see Chapter 4 Converting EDI to XML.
279
280
Description
Editable
Affects XML
Input File
No
Input
Encoding
Yes
No
Physical
Size
No
No
Portion
Loaded
No
No
Characters
Loaded
No
No
Character
Unicode
Value
No
No
281
282
Property
Description
Editable
Affects XML
XML Output
URL
Yes
Yes
Output
Encoding
Yes
Yes
Root
Element
Name
Yes
Yes
Namespace
Prefix
Yes
Yes
Namespace
Yes
Yes
DOCTYPE
System ID
Yes
Yes
DOCTYPE
Public ID
Yes
Yes
XML
Schema
Document
Yes
Yes
Description
Editable
Affects XML
XML
Schema
Namespace
Yes
Yes
Indent
XML?
Yes
Yes
283
284
Property
Description
Editable
Affects XML
Region Type
No
Region
Element
Name
Yes
Yes
Element
Name
Source
Yes
Yes
Rows to Skip
Yes
Yes
Omit from
Output
Yes
Yes
Size
No
No
Portion of
File
No
No
Row Count
No
No
Row
Length+
No
No
Line
Terminator*
Yes
No
Description
Editable
Affects XML
Separator*
Yes
No
Delimiter
Pairs*
Yes
No
Comment
String
Yes
Yes
Escape
Characters*
Yes
Yes
Toss
Characters*
Yes
Yes
Key=Value
Character
Yes
Yes
Component
Separator*
Yes
Yes
SubComponent
Separator*
Yes
Yes
285
Description
Editable
Affects XML
Region
Terminator
Yes
No
Collapse
Consecutive
Field
Separators*
Yes
Yes
Double
Delimiter to
Escape
Yes
Yes
286
Description
Editable
Affects XML
Row
Element
Name
Yes
Yes
Match
Pattern
Yes
Yes
Current Row
Length
No
No
Fields in
Current Row
No
No
Max Fields
in Row
No
No
287
Description
Editable
Affects XML
Field
Element
Name
Yes
Yes
Component
Element
Name
The name you want to use for subfields detected by Stylus Studio (based
on the Component Separator
character) in the XML output. The
default value is component.
Yes
Yes
SubComponent
Element
Name
The name you want to use for subfields detected by Stylus Studio (based
on the Sub-Component Separator
character) in the XML output. The
default value is subcomponent.
Yes
Yes
Source Data
Type
No
Yes
288
Description
Editable
Affects XML
Number
No
No
Cursor
Position
No
No
Offset
No
No
Length
No
No
Max Field
Length *
No
No
Value
No
No
289
Common Properties
All data types support these properties:
Table 28. Common Properties
Description
Lookup List
Yes
Notes
No
Yes
290
Affects
XML
Property
Yes
Description
Editable
Affects XML
Architecture
Yes
Yes
NBCD Signed
NBCD Unsigned
Excess-3
BCD 2421
BCD 84-2-1
Packed
Yes
Yes
Scaling
Factor
(10^n)
Yes
Yes
291
Description
Editable
Affects XML
Rendering
Yes
Yes
292
1.
2.
If the field contains all binary ones (that is, all 0xFF values), it is true.
3.
If the field is one byte long and contains a 0x01 value, it is true.
4.
If the first or last byte in the field contains a 0x01 and all of the other bytes are 0x00,
it is true.
5.
If the contents of the field match any of the items in the True Value Match List or False
Value Match List, then the value is true or false respectively.
Description
Editable
Affects XML
True Value
Match List
Yes
Yes
Yes
Yes
yes
true
.y.
.t.
no
false
.n.
.f.
Yes
Yes
False Output
As
Yes
Yes
293
Description
Editable
Affects XML
Unknown
Output As
Yes
Yes
Left
Padding,
Right
Padding
Yes
Yes
294
Description
Signed
true (default)
Scaling
Factor
(10^n)
Editable
Affects XML
Yes
Yes
Yes
Yes
295
Description
Editable
Affects XML
Scaling
Factor
(10^n)
Yes
Yes
296
1.
If the length is 3, then the day, month and year are read as binary values in the Date
Format order. The Window for Two-digit Years value is used to determine the century.
If the format is YJ, then the first byte is the year, and the second two are the day
number in the year, stored as LSB, MSB.
2.
If the length is 6, then the same is used, except each day/month/year is taken as two
digits.
3.
If the length is 8 and there are no separators, then the day and month each get two
digits and the year gets four.
4.
Description
Editable
Affects XML
Date Format
Yes
Yes
Yes
Yes
YMD
Separator
DMY (day-month-year)
MDY (month-day-year)
YMD (year-month-day)
297
Description
Editable
Affects XML
Window for
Two-digit
Years
Yes
Yes
Left
Padding,
Right
Padding
Yes
Yes
298
Description
Editable
Affects XML
Date-Time
Separator
Yes
Yes
299
Description
Editable
Affects XML
Scaling
Factor
(10^n)
Yes
Yes
Yes
Yes
300
Big
Description
Editable
Affects XML
Scaling
Factor
(10^n)
Yes
Yes
Yes
Yes
Big
301
Description
Signed
true (default)
Scaling
Factor
(10^n)
Editable
Affects XML
Yes
Yes
Yes
Yes
Yes
Yes
302
Big
Description
Signed
true (default)
Scaling
Factor
(10^n)
Editable
Affects XML
Yes
Yes
Yes
Yes
Yes
Yes
Big
303
304
Property
Description
Editable
Affects XML
Decimal
Yes
Yes
Thousands
Yes
Yes
Base
Yes
Yes
Description
Editable
Affects XML
Scaling
Factor
(10^n)
Yes
Yes
Yes
Yes
305
Description
Use
Currency
Conventions
no
Left
Padding,
Right
Padding
Editable
Affects XML
Yes
Yes
Yes
Yes
306
Description
Signed
true (default)
Scaling
Factor
(10^n)
Editable
Affects XML
Yes
Yes
Yes
Yes
Yes
Yes
Big
307
Description
Normalize
White Space
Left
Padding,
Right
Padding
Editable
Affects XML
Yes
Yes
Yes
Yes
308
2.
3.
4.
If the length is six or more, then the hours are the first two characters, the minutes are
the next two characters, and the seconds are the next two digits.
5.
If the length is four or five, then the hours are the first two characters, and the minutes
are the next two characters.
6.
7.
If an HMS separator was seen, then the following rules are tried:
8.
9.
Up to two more digits become the minute, also terminated by the HMS separator.
10.
If there are any more digits, the next two become the seconds value.
11.
If there is a decimal character and more digits, they become fractional parts of the
seconds.
12.
309
Wrapping is performed for seconds >= 60 and minutes >= 60. Hours are moduloed
with 24.
Description
Editable
Affects XML
HMS
Separator
Yes
Yes
Yes
Yes
310
Description
Editable
Affects XML
Scaling
Factor
(10^n)
Yes
Yes
311
The following table summarizes commonly used control characters. For more
information, visit http://www.unicode.org.
Table 45. Commonly Used Control Characters
312
Decimal
Hex
Mnemonic
Control Key
0x00
NUL
^@, '\0'
0x01
SOH
^A
0x02
STX
^B
0x03
ETX
^C
0x04
EOT
^D
0x05
ENQ
^E
0x06
ACK
^F
0x07
BEL or BELL
^G, '\a'
0x08
BS
^H, '\b'
0x09
TAB or HT
^I, '\t'
10
0x0A
LF
^J, '\n'
11
0x0B
VT
^K, '\v'
12
0x0C
FF
^L, '\f'
13
0x0D
CR
^M, '\r'
14
0x0E
SO
^N
15
0x0F
SI
^O
16
0x10
DLE
^P
17
0x11
DC1 or XON
^Q
18
0x12
DC2
^R
19
0x13
DC3 or XOFF
^S
20
0x14
DC4
^T
21
0x15
NAK
^U
Hex
Mnemonic
Control Key
22
0x16
SYN
^V
23
0x17
ETB
^W
24
0x18
CAN
^X
25
0x19
EM
^Y
26
0x1A
SUB
^Z
27
0x1B
ESC
^[
28
0x1C
FS
^\
29
0x1D
GS
^]
30
0x1E
RS
^^
31
0x1F
US
^_
127
0x7F
DEL
128
0x80
129
0x81
130
0x82
BPH
131
0x83
NBH
132
0x84
IND
133
0x85
NEL
134
0x86
SSA
135
0x87
ESA
136
0x88
HTS
137
0x89
HTJ
138
0x8A
VTS
139
0x8B
PLD
313
314
Decimal
Hex
Mnemonic
140
0x8C
PLU
141
0x8D
RI
142
0x8E
SS2
143
0x8F
SS3
144
0x90
DCS
145
0x91
PU1
146
0x92
PU2
147
0x93
STS
148
0x94
CCH
149
0x95
MW
150
0x96
SPA
151
0x97
EPA
152
0x98
SOS
153
0x99
154
0x9A
SCI
155
0x9B
CSI
156
0x9C
ST
157
0x9D
OSC
158
0x9E
PM
159
0x9F
APC
160
0xA0
NBSP
173
0xAD
SHY
Control Key
Chapter 4
Support for the EDI to XML module is available only in Stylus Studio XML
Enterprise Suite.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the EDI to XML
module video.
This chapter describes how to use the Stylus Studio EDI to XML module to convert
standard and proprietary EDI to XML.
This chapter covers the following topics:
315
Need to convert an EDI document that does not conform to an EDI standard
Want to create a conversion definition that allows you to convert other nonconforming EDI documents
Want to experiment with different XML Converter settings to see how they affect the
conversion process and the resulting XML
Want to create scenarios that use different EDI documents, based on different EDI
standards, or that use different XML Converter settings
You can perform all of these operations and others using the EDI to XML editor.
This section covers the following topics:
View an EDI file you want to convert to XML. The EDI document pane shows any
errors in the file that is, how the file deviates from the EDI standard on which it is
based and provides Quick Fixes and other tools to help you correct the errors.
317
You can import a local copy of EDI standard definitions and modify them in
numerous ways adding new values to a code list, changing a segments Requirement
property from Mandatory to Optional, and so on. See Customizing an EDI Standard
on page 340 for more information on this topic.
Specify properties for the DataDirect XML Converter. The EDI to XML module uses
the DataDirect XML Converter engine to convert EDI to XML. See Specifying
XML Converter Properties on page 339 for more information on this topic.
Preview the EDI to XML conversion. When you click the Preview Result button ( ),
Stylus Studio opens the Preview window and displays the XML that results from
converting the source EDI document using the parameters specified for the XML
Converter engine as well as changes made to the EDI standard, if any.
Using Undo
Undo (Edit > Undo, or Ctrl+z) is supported throughout the EDI to XML editor. For
example, you can undo changes made to
made to the EDI structure definition, use the Restore Definition feature. See Undoing
Customizations on page 358 for more information.
318
Referencing it in the converter:EDI URI scheme the user= property allows you to
specify the URI of a SEF file. (The easiest way to make changes to the converter: URI
scheme is through the XML Converter properties. See Specifying XML Converter
Properties on page 339 and EDI XML Converters Properties Reference on
page 375 for more information on these topics.)
Invoking the setEDIExtension() method that is part of the XML Converter API. This
method is available in both Java and .NET interfaces. See How XML Converters are
Used in Stylus Studio on page 214 for more background information on the
DataDirect XML Converter in Stylus Studio, or refer to the DataDirect XML
Converter documentation that is part of your Stylus Studio installation
\components\XML Converters for .NET and \components\XML Converters for Java
where you installed Stylus Studio.
Open the SEF file in Stylus Studio and create a new scenario using a new EDI
document as the source document you want to convert to XML.
Stylus Studio infers the EDI standard based on the source EDI document that is being
used to create the EDI to XML conversion
You can specify the EDI standard explicitly (whether or not you are using a source
EDI document)
319
The EDI dialect and version associated with an EDI to XML conversion is always
displayed in the EDI to XML editor.
You can change the EDI dialect and/or version any time you are working with the EDI to
XML editor using the Select Dialect and Select Version fields.
An existing EDI document. Use this method when you have a sample EDI document
that is representative of other documents in your enterprise that will need to be
converted to XML.
An EDI standard. Use this method when you do not have a sample EDI document but
know how your proprietary EDI differs from one of the EDI standards (dialect and
version) supported by Stylus Studio.
The following sections use sample files installed with Stylus Studio to illustrate the
conversion process and features of the EDI to XML module. See Example: Converting
a Conforming EDI File on page 323 and Example: Converting a Non-conforming EDI
File on page 326 for more information.
320
1.
Select File > New > EDI to XML Conversion from the Stylus Studio menu.
The New EDI to XML Conversion dialog box appears.
2.
In the Select a sample EDI document field, type the URI for the EDI document you
want to use as the model for your EDI to XML conversion.
Stylus Studio User Guide
Click OK.
The EDI to XML editor appears. The EDI document is displayed in the EDI
document pane; the EDI structure for the EDI standard on which the document is
based is displayed in the EDI Structure pane.
4.
To save your work in the EDI to XML editor, select File > Save from the Stylus Studio
menu.
Stylus Studio displays the Save As dialog box, prompting you to save the file with a
.sef extension.
Select File > New > EDI to XML Conversion from the Stylus Studio menu.
The New EDI to XML Conversion dialog box appears.
2.
Select the Select the dialect and version you need to customize radio button.
3.
Use the Dialect and Version fields in the Select the dialect and version you need to
customize group box to select the dialect and version of the EDI standard you want
to customize.
4.
Click OK.
The EDI to XML editor appears. The EDI structure for the EDI standard you selected
is displayed in the EDI Structure pane. The EDI document pane is empty.
You can change the dialect and version using the drop-down lists at the top of the EDI
to XML editor.
5.
To save your work in the EDI to XML editor, select File > Save from the Stylus Studio
menu.
Stylus Studio displays the Save As dialog box, prompting you to save the file with a
.sef extension.
321
Click the Edit scenario properties button ( ) on the EDI to XML editor tool bar.
Alternative: Select EDI > Scenario Properties from the Stylus Studio menu.
Alternative: Select Create Scenario from the scenario drop-down list on the EDI to
XML editor tool bar.
by selecting it in this list, but it can be more convenient to select it from the Create
Scenario from the scenario drop-down list on the EDI to XML editor tool bar:
When you choose a new active scenario, Stylus Studio uses the EDI input and output URI
specified in the scenario when you preview the EDI to XML conversion.
Select the scenario you want to preview from the scenario drop-down list on the EDI
to XML editor tool bar.
2.
Select File > New > EDI to XML Conversion from the Stylus Studio menu.
The New EDI to XML Conversion dialog box appears.
2.
In the Select a sample EDI document field, type the URI for the 831.x12 EDI file.
323
Click OK.
The EDI to XML editor appears. The 831.x12 EDI file you selected in Step 2 is
displayed in the EDI document pane. The message in the status bar (No errors found)
indicates that the 831.x12 EDI file has no errors.
The EDI Structure pane displays information for X12 version 004030 from the
DataDirect XML Converter repository. Stylus Studio uses this information to parse
and validate the source EDI document associated with this EDI to XML conversion.
Since the 831.x12 EDI file has no errors and appears to conform to the X12 standard,
it is ready to be converted to XML. (For information on addressing errors in EDI files,
see Resolving EDI Document Errors on page 332.)
324
To convert the 831.x12 EDI file to XML, click the Preview Result button ( ).
The Save As dialog box appears, requesting that you save your EDI to XML
conversion as a SEF file.
Provide a name for the file and click the Save button.
Stylus Studio opens the Preview window and displays the XML that results from
converting the 831.x12 EDI file.
Note that no changes were made to either the EDI structure for the X12 standard or to the
default converter settings used by the XML Converter engine (as shown in the URI field).
Sometimes you will need or want to create local copies of EDI standards definitions or
change properties used by the XML Converter engine. These topics are discussed in the
following example, Example: Converting a Non-conforming EDI File on page 326, as
well as in greater detail in Specifying XML Converter Properties on page 339 and
Customizing an EDI Standard on page 340.
325
326
1.
Select File > New > EDI to XML Conversion from the Stylus Studio menu.
The New EDI to XML Conversion dialog box appears.
2.
In the Select a sample EDI document field, type the URI for the code99.x12 EDI file.
Alternative: Use the more button ( ) to locate code99.x12.
When you select the document, X12 is displayed in the Dialect field and 004030 is
displayed in the Version field in the Select the dialect and version you need to
customize group box.
3.
Click OK.
The EDI to XML editor appears. The code99.x12 EDI file you selected in Step 2 is
displayed in the EDI document pane.
The message in the status bar (No errors found) indicates that the code99.x12 EDI file
has no errors. Or at least none that is apparent based on the default settings for the
properties used by the XML Converter engine.
By default, the XML Converter engine does not validate code list tables. However,
since our application development policy requires that we validate code lists, we need
to change the code list validation property.
To display the property settings for the XML Converter, click the more button (
to the right of the converter URI field.
Stylus Studio displays the Select XML Converters Properties dialog box.
The property that controls code list validation is Force error if value not in code list
(tbl).
5.
327
With code list validation on, we see that our EDI source document contains an error
(indicated by a red squiggle at the errors location in the EDI document pane. If you
hover the pointer over the red squiggle, a tool tip provides more information about the
error:
328
When we alert our provider to this error, he informs us that all EDI documents he
provides us for processing will include this code value in the Transaction Set Purpose
Code code list, as it does in the code99.x12 EDI file we are using to build our EDI to
XML conversion:
Figure 198. Clicking the EDI Document Back-maps to the EDI Structure
7.
329
that the Transaction Set Purpose Code code list value 99 is not defined in the X12
standard:
We know we can ignore the error by suppressing code list validation (as seen earlier
in this example). But to accommodate the new code value, we need to add it to the
Transaction Set Purpose Code code list. We do this by modifying a local copy of the
Transaction Set Purpose Code code list to include code 99. This modification to the
standard will exist only in the SEF file that is used to convert other files of this type;
we are not changing the definition of the EDI standard in the DataDirect XML
Converter repository.
330
Enter 99 in the Value field; enter Status Under Review in the Description field, and
click OK.
The values in the Transaction Set Purpose Code code list tree are displayed in bold,
indicating that this definition (and any changes to it) is local, stored in the SEF file
that represents our EDI to XML conversion. (For more information, see
Customizing an EDI Standard on page 340.)
After a moment, Stylus Studio reloads the source EDI document. The red squiggle
does not appear because we have added 99 to the code list table; the status bar displays
an OK symbol ( ) and the message, No errors found. The EDI to XML conversion
can now be tested.
10.
To convert the code99.x12 EDI file to XML, click the Preview Result button (
The Save As dialog box appears, requesting that you save your EDI to XML
conversion as a SEF file.
11.
Provide a name for the file and click the Save button.
Stylus Studio opens the Preview window and displays the XML that results from
converting the code99.x12 EDI file
).
331
Code list values that are not defined in the EDI standard
332
Example
Description
A red background
indicates that the EDI
dialect specified in the
document does not agree
with the dialect specified
in the EDI to XML editor.
A yellow background
indicates that the EDI
version specified in the
document does not agree
with the version specified
in the EDI to XML editor.
Data error
The number of data errors identified is summarized in the status bar. Prev and Next
buttons (and their keyboard equivalents) help you navigate from one error to the next.
Note that incorrect dialect and version are not included in this count.
333
F4 and Next button in the status bar moves the cursor to the next error in the source
EDI document
Shift+F4 and the Prev button in the status bar moves the cursor to the previous error
in the source EDI document
When the cursor stops on an error in the EDI document, Stylus Studio expands the
corresponding node in the EDI Structure tree to show the related EDI definition. The
Properties window also shows properties for that definition.
The tool tip provides information about the error and suggestions for correcting it.
334
Stylus Studio changes the value in the Select Dialect or Select Version fields at the top of
the EDI to XML editor and the red or yellow background is cleared.
Note that you can change the dialect and version manually any time you need using the
drop-down lists:
Quick Fixes
The Quick Fixes feature displays one or more ways to address a given error. Quick Fixes
is available for data errors only.
335
To display Quick Fixes choices, right-click on a document error (the red squiggle) in the
EDI document pane and choose Quick Fixes from the shortcut menu. The menu displays
the fixes that are available for the current error:
Fixes (when there is more than one) are listed in increasing order of scope when
possible, the scope of the first choice is limited to the current error (or class of error) only;
other fixes listed are typically broader in scope (turning off a type of checking or
validation, for example).
Change the value of a property in the EDI structure. For example, error DDEE0004
indicates that a mandatory element was missing. One Quick Fix for this type of error
is to change that elements Requirement property from Mandatory to Optional. This
results in importing a local copy of the segments definition to the SEF file and
changing the elements Requirement property. This change affects the specific
definition only and might be appropriate if you want to do validation in general, but
in this specific context, you do not require a value for the element.
You can import and change EDI standard definitions at any time. See Customizing
an EDI Standard on page 340 for more information.
Ignore a specific error number in this example, ignore all DDEE0004 errors. This
has the effect of treating all elements as optional. This is appropriate if you want to
convert the data without checking if all mandatory elements are present.
Change an XML Converter property. In this example, the suggestion would be to use
opt=yes, which treats all elements and segments as optional. This is appropriate if you
want to convert the data and do little or no validity checking.
You can change the XML Converter properties at any time. See Specifying XML
Converter Properties on page 339 for more information.
336
Add missing values to a local copy of the EDI standard code list.
Add a special value, ... that suppresses code list validation for that table only.
When you enter ... for a code list value, any elements with values not in the codelist are
treated as valid. Further, if you provide a description for the ... code list value when you
create the code, that value is output in the XML comments. Here, for example, any
Stylus Studio User Guide
337
missing values from the Piece Identification Indicator code list table are output to XML
with the comment missing:
Figure 207. Providing Descriptions for Missing Code List Table Values
Note that the ... code value affects code list validation only for the table for which it was
created. Code list validation for other tables is unaffected.
See Example: Converting a Non-conforming EDI File on page 326 for an example of
modifying a code list; see Creating a Code on page 354 to learn how to add a value to
a code list.
Tip You can add the ... code list value on-the-fly using the Quick Fixes feature. See Quick
338
The settings you specify here are saved with the SEF file for your EDI to XML conversion
and are displayed in the URI field (in converter:EDI URI scheme format) at the top of the
EDI to XML editor.
See EDI XML Converters Properties Reference on page 375 for detailed information
about XML Converter properties.
To display the Select XML Converters dialog box:
339
340
Modify definitions in a local copy of the EDI standard add a value to a code list,
remove a segment reference, and so on.
Import definitions you might want to import code list values from a current EDI
standard into an EDI to XML conversion based on a prior standard, for example.
Here, both 831: Application Control Totals and Group 1: AMT are shown in bold because
those definitions have changed based on the addition of the DFI: Default Information
segment reference.
341
The EDI dialect and version declared in the EDI document you are converting
Any customized definitions you have created (shown in bold in the EDI Structure
pane)
The complete specification for the EDI standard you have selected, including local
definitions
342
When you create an EDI to XML conversion (whether based on an EDI document or
starting directly from an EDI standard), the EDI Structure pane makes the complete
specification accessible just expand a node to view a definition, and its properties appear
in the Properties window.
As you build your EDI to XML conversion and make changes to the EDI standard, you
might want to simplify the view in the EDI Structure pane to display only those local
definitions. In the following illustration, the segments A1, A2, and AC have all been
343
imported from repository. These definitions, which are shown in bold, reside in the SEF
file that represents your EDI to XML conversion.
Message
Segment
Element
Composite
Code list
Structure definitions can be created from anywhere in the EDI Structure that is, context
(as shown by cursor placement or focus) does not matter. New structure definitions are
placed in the appropriate EDI structure folder, sorted alphanumerically. Creating a new
structure definition does not affect existing definitions in the EDI Structure.
This section covers the following topics:
344
Adding a Message
To add a message:
1.
Right-click any node in the EDI Structure and select New Definition > Message from
the shortcut menu.
Alternative: Select EDI > New Definition > Message from the Stylus Studio menu.
The Message Definition dialog box appears.
3.
Click OK.
The message definition is added to the existing transaction messages in the EDI
Structure; new messages are sorted in alphanumeric order.
Adding a Segment
To add a segment:
1.
Right-click any node in the EDI Structure tree and select New Definition > Segment
from the shortcut menu.
Alternative: Select EDI > New Definition > Segment from the Stylus Studio menu.
345
3.
Click OK.
The segment definition is added to the existing segments in the EDI Structure; new
segments are sorted in alphanumeric order.
Adding an Element
To add an element:
1.
Right-click any node in the EDI Structure and select New Definition > Element from
the shortcut menu.
Alternative: Select EDI > New Definition > Element from the Stylus Studio menu.
The Element Definition dialog box appears.
346
Enter an element name and specify a data type (the default is AN Alphanumeric).
3.
4.
Click OK.
The element definition is added to the existing elements in the EDI Structure; new
elements are sorted in alphanumeric order.
Adding a Composite
To add a composite:
1.
Right-click any node in the EDI Structure and select New Definition > Composite
from the shortcut menu.
Alternative: Select EDI > New Definition > Composite from the Stylus Studio menu.
The Composite Definition dialog box appears.
3.
Click OK.
The composite definition is added to the existing composites in the EDI Structure;
new composites are sorted in alphanumeric order.
Right-click any node in the EDI Structure and select New Definition > Code List from
the shortcut menu.
Alternative: Select EDI > New Definition > Code List from the Stylus Studio menu.
347
See Creating a Code on page 354 to learn how to add values to a code list.
348
When you add a definition, it is added to the end of the existing definition. For
example, if you add an element reference to a segment, the new element reference is
added after the last element reference currently defined for that segment.
To add a definition, choose Add from the shortcut or Stylus Studio menu.
When you insert a definition, you get to choose whether to place it before or after the
current definition. For example, if the focus is on a segment reference, you can choose
whether to place a new group before or after the segment reference.
To insert a definition, choose Insert After or Insert Before from the shortcut or Stylus
Studio menu.
Right-click the message or group definition to which you want to add the segment
reference and select Add > Segment Reference from the shortcut menu.
Alternative: Select EDI > Add > Segment Reference from the Stylus Studio menu.
The Add Segment Reference dialog box appears.
Choose the segment you want to reference, or click New Segment to create a new
segment as your segment reference. See Adding a Segment on page 345 for
information on creating segments.
349
Choose the setting for the Modifier property you can leave this field blank, or you
can define the segment reference as Dependent, Must Be Used, Not Recommended,
Not Used, or Used.
4.
Choose the setting for the Requirement property you can choose Conditional,
Facultative, Mandatory, or Optional.
5.
Choose the setting for the Maximum Use, Ordinal, and Position property. You can use
the default values if appropriate.
6.
Creating a Group
You can create a group for a message or another group. You can use an existing segment
for the groups loop trigger or create a new segment and use that.
To create a group:
1.
Right-click the message or group definition to which you want to add the group and
select Add > Group from the shortcut menu.
Alternative: Select EDI > Add > Group from the Stylus Studio menu.
The Group Definition dialog box appears.
350
Choose the segment you want to use as the loop trigger, or click New Segment to
create a new segment as your loop trigger. See Adding a Segment on page 345 for
information on creating segments.
4.
Choose the setting for the Modifier property you can leave this field blank, or you
can define the segment reference as Dependent, Must Be Used, Not Recommended,
Not Used, or Used.
5.
Choose the setting for the Requirement property the default is Conditional, but you
can choose Facultative, Mandatory, or Optional.
6.
Choose the setting for the Maximum Use property. You can use the default value if
appropriate. You can specify Ordinal or Position properties for a group definition only
if the Loop Sequence property for the EDI Structure is set to Enable.
7.
Right-click the definition to which you want to add the element or composite
reference and select Add > Element or Composite Reference from the shortcut menu.
Alternative: Select EDI > Add > Element or Composite Reference from the Stylus
Studio menu.
351
Choose the element or composite you want to reference, or click New Element or New
Composite to create a new element or composite to reference. See Adding an
Element on page 346 or Adding an Element on page 346 for information on
creating these definitions.
352
3.
Choose the setting for the Modifier property you can leave this field blank, or you
can define the reference as Delete, Dependent, Must Be Used, Not Recommended,
Not Used, or Used.
4.
Choose the setting for the Requirement property the default is Conditional, but you
can choose Facultatif (composite reference) or Dependent (element reference),
Mandatory, or Optional.
5.
Enter the value for the Repeat Count, Minimum, Maximum, and Ordinal properties.
You can use the default value, if available and appropriate.
6.
Creating a Repetition
You can create a repetition for a segment, composite, segment or composite reference, or
another repetition. A repetition is created as a child of the definition. It is given the label
REPEAT in the EDI Structure.
To create a repetition:
1.
Right-click the definition for which you want to create a repetition and select Add >
Repetition from the shortcut menu.
Alternative: Select EDI > Add > Repetition from the Stylus Studio menu.
The repetition is added to the definition.
Creating a Variation
You can create a variation for a segment or a composite. A variation results in the cloning
of the segment or composite on which it is based. The original definition is given the label
in the EDI Structure of # Base; the first variation is labeled #1. Subsequent variations are
labeled #2, #3, and so on. The first # is the symbol for the tree node, and not part of the
name.
To create a variation:
1.
Right-click the definition for which you want to create a variation and select Add >
Variation from the shortcut menu.
Alternative: Select EDI > Add > Variation from the Stylus Studio menu.
The variation is added to the definition.
353
Creating a Code
You can add a code to an element, an element reference, a code list, or another code. You
can create a single code (99, for example) or a range of codes (AA to AZ, for example).
To create a code definition:
1.
Right-click the definition to which you want to add the code definition and select Add
> Code from the shortcut menu.
Alternative: Select EDI > Add > Code from the Stylus Studio menu.
The Code Definition dialog box appears.
354
2.
A single code, enter a value in the Value field and, optionally, a description in the
Description field.
A range of codes, select the Range radio button, and enter range values in the
Begin and End fields.
3.
355
356
1.
Open the EDI to XML conversion whose EDI structure you want to update by
importing an EDI Standard.
2.
In the EDI Structure pane, select the definition you want to import.
Here, we have selected 9: Late Reason Code. Note that the last code defined for this
code list (in version 004030) is LA = Intermittent Lost Time Prior to First Payment.
4.
Right-click the code list 9: Late Reason Code, and choose Import Definition from the
shortcut menu.
This directs Stylus Studio to import the codes for this code list from X12 version
005050 into the local EDI Structure.
5.
Change the version back to 004030 (since this is the version on which the EDI to
XML conversion is based).
357
Click the Show Full Dialect Specification button ( ). Note that the 9: Late Reason
Code code list appears in bold to indicate that a local copy of this definition has been
created.
Undoing Customizations
You can undo any customizations you make using the Restore feature in the EDI to XML
editor. When you undo a customization, the modified definition reverts to its EDI
standard, effectively removing it from the SEF file for your EDI to XML conversion.
Tip You can use Undo to undo changes incrementally, backing out changes one at a time. See
358
In the EDI Structure tree, select the modified EDI standard definition whose change
you want to undo.
Modified definitions are displayed in bold text. Use the Show Full Dialect
) to toggle the display of modified standards in the EDI
Structure tree.
Tip
Specification button (
2.
Right-click the modified definition and select Restore Definition from the short cut
menu.
Alternative: Select EDI > Restore Definition from the Stylus Studio menu.
The modified definition reverts to its EDI standard; it is removed from the SEF file
for your EDI to XML conversion and no longer appears in bold text in the EDI
Structure tree.
Removing a Definition
In addition to adding and changing definitions, you can modify your local copy of an EDI
standard by removing a definition. You can remove the following definitions:
Composite references
Element references
Segment references
Groups
Repetitions
Variations
Use care when removing references and groups, as this can have unintended
consequences regarding the expected structure of an EDI document and numbering.
Tip If you want to remove a definition because that structure is never used by the EDI
359
In the EDI Structure tree, select the definition you want to remove from the EDI
Structure.
2.
Right-click the definition and select Remove from the short cut menu.
Alternative: Select Remove from the Stylus Studio menu.
The definition is removed from the EDI Structure tree.
Generate XQuery/XML Schema use this tool when you are working in the EDI to
XML editor. The current context of the EDI dialect, version, and message type
provide much of the information used to generate the XQuery and/or XML Schema.
The SEF file associated with your EDI to XML Conversion also provides information
that has an impact on the generated XQuery/and or XML Schema.
EDI to XQuery document wizard use the EDI to XQuery document wizard when
you want to generate XQuery and/or XML Schema from an EDI message but are not
currently working in the EDI to XML editor.
360
1.
In the EDI to XML editor, select the EDI message for which you want to generate
XQuery and/or XML Schema from the EDI structure pane.
2.
4.
Click OK.
Displays the name of the message; based on the message that was active in the EDI
Structure pane of the EDI to XML editor when you selected EDI > Generate
XQuery/XML Schema from the menu.
Mode
Whether the EDI is processed in batch or interactive mode. Valid for EANCOM,
EDIFACT, and IATA (Cargo-IMP and PADIS) only.
Create XQuery for this EDI Message A check box you use to indicate that you want to
XQ File The URI for the file to which the generated XQuery is written. By
default, this is Untitledn_name.xquery file, where n is a unique number and name
is the EDI message name abbreviation.
361
Mandatory segments and elements only Generates only those segments whose
Requirement property is mandatory and, for them, only the mandatory element
and composite references.
All segments but only mandatory elements Generates all segments, but, for
each of them, only the mandatory element and composite references.
All segments and elements Generates all segments, and all element and
composite references specified for them.
Create XML Schema for this EDI Message A check box you use to indicate that you
want to generate XML Schema for the EDI message.
XSD File The URI for the file to which the generated XML Schema is written.
By default, this is Untitledn_name.xsd file, where n is a unique number and name
is the EDI message name abbreviation.
Write annotations describing each element Whether or not you want the
generated XML Schema to include annotations that are part of the EDI message.
Enumerations for elements that have codelists Whether or not you want the
generated XML Schema to include enumerations for fields that have lists of
values.
362
In the Stylus Studio, select File > Document Wizards from the menu.
The Document Wizard dialog box appears.
Click the XQuery tab and double-click the EDI to XQuery icon.
The Generate XQuery from EDI Standards dialog box appears.
4.
Click OK.
You use the fields in the Message group box to specify information about the EDI
standard for which you want to generate XQuery.
363
Dialect Drop-down list that lets you specify the EDI dialect for which you want
to generate XQuery.
Version Drop-down list that lets you specify the version for the EDI dialect you
selected.
Mode Whether the EDI is processed in batch or interactive mode. Valid for
EANCOM, EDIFACT, and IATA only.
Message/Description The specific EDI message for which you want to generate
the XQuery.
XML Structure
You use the fields of the XML Structure group box to specify the structure of the XML
Use long names for Whether or not you want to use the long element and/or
segment names as part of the XML tag UNB01-SyntaxIdentifier versus UNB01,
for example.
Wrap GROUP element around message groups Whether you want to wrap
a <GROUP> element around transaction messages. This can make message
groupings easier to handle with XPath for EDI document with multiple message
groups.
Prefix GROUP_N tags with the message name Adds the message name to the
GROUP_n prefix in the XML element tag. For example, <TS_831_GROUP_1>.
Put the data value in value= attributes Places code list data values in an value=
string in the element tag. For example, <BGN01 value="00"><!--353: Transaction
Set Purpose Code--></BGN01>. By default, the data value is output to XML as text
(<BGN01><!--353: Transaction Set Purpose Code-->00</BGN01>).
Put decoded data values in decode= attributes Places decoded code list data
values in a decode= string in the element tag. For example, <ISA15
decode=Production Data>. By default, the decoded value is not output to XML.
XQuery Generate Options
You use the XQuery Generation Options group box to specify what EDI structures
you want represented in the generated XQuery. XQuery resulting from the document
wizard is output as an Untitledn.xquery file, where n is a unique number, directly to
the Stylus Studio desktop.
Mandatory segments and elements only Generates only those segments whose
Requirement property is mandatory and, for them, only the mandatory element
and composite references.
All segments but only mandatory elements Generates all segments, but, for
each of them, only the mandatory element and composite references.
364
All segments and elements Generates all segments, and all element and
In addition to generating XQuery for an EDI message, you can choose to generate an
XML Schema for the same message at the same time. The fields in this group box
allow you to specify the settings that are used to generate the XML Schema for the
selected EDI message.
XSD File The URI for the XML Schema (.xsd) file that is output by the
document wizard.
Write annotations describing each element Whether or not you want the
generated XML Schema to include annotations that are part of the EDI message.
Enumerations for elements that have codelists Whether or not you want the
generated XML Schema to include enumerations for fields that have lists of
values.
when generating XML in XQuery and XML Schema files. The SEF file can augment
information that Stylus Studio uses to generate XQuery and XML Schema customized
EDI definitions are stored in the SEF file, for example. If the same setting is specified by
both the document wizard and the SEF file, the SEF file value is used.
365
Description
Editable
Type
No
Name
Yes
Composite Properties
Table 48. Code List Properties
Property
Description
Editable
Type
No
Name
Yes
Description
Yes
Syntax Rules
Yes
Rules entered in this field are preserved, but the rule is not
enforced at runtime.
366
Description
Editable
Type
No
Modifier
Yes
Yes
Yes
Ordinal
Yes
Yes
367
Description
Editable
SEF Version
Yes
Loop
Sequence
Enabled
Yes
Description
Yes
Element Properties
Table 51. Element Properties
368
Property
Description
Editable
Type
No
Name
Yes
Datatype
Yes
Code List
Yes
Minimum
Length
Yes
Maximum
Length
Yes
Description
Yes
Description
Editable
Type
No
Modifier
Yes
Yes
Yes
Minimum
Length
Yes
Maximum
Length
Yes
Ordinal
Yes
369
Description
Editable
Rename
XML Node
Yes
Yes
Group Properties
Table 53. Group Properties
Property
Description
Editable
Type
No
Modifier
Yes
370
Description
Editable
Requirement
Yes
Yes
Append
Counter to
XML Node
Yes
Ordinal
Yes
Position
Yes
This field is grayed out unless you have set the EDI Structure
<hyperlink>Loop Sequence Enabled property to Enable.
Rename
XML Node
Yes
Message Properties
Table 54. Message Properties
Property
Description
Editable
Type
No
Name
Yes
371
Description
Editable
Description
Yes
Rename
XML Node
Yes
Repetition Properties
Table 55. Repetition Properties
Property
Description
Editable
Type
No
Repetition
Yes
Segment Properties
Table 56. Segment Properties
Property
Description
Editable
Type
No
Name
Yes
Description
Yes
Syntax Rules
Yes
Rules entered in this field are preserved, but the rule is not
enforced at runtime.
372
Description
Editable
Allow
multiple tail
components
For the HL7 dialect, this property allows the last element
(whether composite or atomic) of that segment to repeat an
unlimited number of times (as long as the overall limit of 254
elements in a segment is not exceeded).
Yes
Yes
Description
Editable
Type
No
Modifier
Yes
Yes
Yes
Ordinal
Yes
373
Description
Editable
Position
Yes
Rename
XML Node
Yes
374
In the \doc folder for DataDirect XML Converters where you installed Stylus Studio
\components\XML Converters for .NET\doc, for example
375
376
Chapter 5
Stylus Studio provides many features for creating, updating, and applying stylesheets.
This section of the documentation covers the following topics:
377
What Is XSLT?
The Extensible Stylesheet Language (XSL) is the World Wide Web Consortium's (W3C)
language for manipulating XML data. XSLT is the component of XSL that allows you to
write a stylesheet that you can apply to XML documents. The result of applying a
stylesheet is that the XSLT processor creates a new XML, HTML, or text document based
on the source document. The XSLT processor follows the instructions in the stylesheet.
The instructions can copy, omit, and reorganize data in the source document, as well as
add new data.
XSL is an XML-based language. It was developed by the W3C XSL working group
within the W3C Stylesheets Activity. The W3C activity group has organized its
specification of XSL into three parts:
XPath specifies the syntax for patterns and expressions used in stylesheets. The XSLT
processor uses an XPath expression to execute a query on the source document to
determine which nodes to operate on. See Writing XPath Expressions on page 691.
XSLT specifies the syntax for a stylesheet that you apply to one XML document to
create a new XML, HTML, or text document.
378
To learn more about the changes from XSLT 1.0 to XSLT 2.0, go to
http://www.w3.org/TR/xslt20/#changes.
What Is a Stylesheet?
A stylesheet is an XML document that contains instructions for generating a new
document based on information in the source document. This can involve adding,
removing, or rearranging nodes, as well as presenting the nodes in a new way.
This following topics provide more information:
Example of a Stylesheet
When you work with a stylesheet, three documents are involved:
379
You can use a stylesheet to transform this XML document into an HTML document that
appears as follows in a Web browser:
The Web page in Figure 227 is defined by the following HTML document:
<html> <head> <title>Stylesheet Example</title> </head>
<body> <table align="center" cellpadding="5">
<tr><th>Title</th><th>Author</th><th>Price</th></tr>
<tr><td>The Divine Comedy</td><td>D. Alighieri</td>
<td align="right">5.95</td></tr>
<tr><td>Hamlet</td><td>W. Shakespeare</td>
<td align="right">2.95</td></tr>
<tr><td>Macbeth</td><td>W. Shakespeare</td>
<td align="right">9.95</td></tr>
</table> </body> </html>
The HTML document contains HTML markup that is not in the source document. In the
HTML document, the data from the source document is not in the same order as it is in
the XML source document. Also, this HTML document does not include some data that
is in the XML source document. Specifically, the HTML document does not include
information about the date of publication (the published elements).
To create this HTML file, the stylesheet contains two templates that provide instructions
for
Wrapping the contents of the title, author, and price elements in table cells
380
XSLT
instruction.
It must be
the root
element in a
stylesheet
in Stylus
Studio.
xsl:template
is an XSLT
instruction. It
contains literal
data to be
copied to the
result document
and XSLT
instructions to
be followed by
the XSLT
processor. The
processor
performs these
steps for the
source nodes
identified by the
match attribute
value. In this
template, the
match attribute
identifies the
root node of the
source
document.
xsl:apply-templates is an
xsl:value-of is an
xsl:sort is an XSLT
381
XSLT elements and attributes. In the previous stylesheet, the XSLT elements are
Non-XSLT elements and attributes. In the previous stylesheet, these include the
HTML elements that create the table.
The root element of a stylesheet must declare a namespace that associates a prefix with
the URI for an XSLT processor. The URI in the namespace declaration in the previous
example identifies the W3C standard XSLT processor. This declaration, shown again
below, instructs the XSLT processor to recognize the XSLT elements and attributes by
their xsl prefix:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
In this stylesheet, you must use the xsl prefix for all XSLT instructions.
Note The Stylus Studio XSLT processor requires the namespace URI to be
http://www.w3.org/1999/XSL/Transform. The prefix can be anything you want. Typically,
it is xsl.
When you write a stylesheet, you specify the actions you want the XSLT processor to
perform when it processes a particular source node. To do this, you define XSLT
templates, which are described in the next section.
What Is a Template?
A template defines what the XSLT processor should do when it processes a particular
node in the XML source document. The XSLT processor populates the result document
by instantiating a sequence of templates. Instantiation of a template means that the XSLT
processor
382
Copies any literal data from the template to the result document
Executes the XSLT instructions in the template
How the select and match Attributes Are Different on page 385
Contents of a Template
The stylesheet example in Example of a Stylesheet on page 379 defines the following
templates using the xsl:template instruction:
<xsl:template match="/">
<html><head><title>Stylesheet Example</title></head>
<body>
<table align="center" cellpadding="5">
<tr><th>Title</th><th>Author</th><th>Price</th></tr>
<xsl:apply-templates select="/bookstore/book">
<xsl:sort select="author">
</xsl:apply-templates>
</table></body></html>
</xsl:template>
<xsl:template match="book">
<tr><td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td align="right"><xsl:value-of select="price"/></td></tr>
</xsl:template>
In the xsl:template tag, the value of the match attribute is an XPath pattern. This pattern
matches (identifies) a node or a set of nodes in the source XML document. The value of
the match attribute is the template rule.
The template body defines actions you want the XSLT processor to perform each time it
instantiates this template. It contains
XSLT instructions you want the XSLT processor to follow; for example, xsl:applytemplates in the first template, and xsl:value-of in the second template.
Elements that specify literal output you want the XSLT processor to insert in the result
document. For example:
<table align="center" cellpadding="5">
383
The XSLT processor instantiates this template to start generating the result document. It
copies the first few lines from the template to the result document. Then the XSLT
processor reaches the following XSLT instruction:
<xsl:apply-templates select="/bookstore/book"/>
When the XSLT processor reaches the select attribute, it creates a list of all source nodes
that match the specified pattern. In this example, the list contains book elements. The
processor then processes each node in the list in turn by instantiating its matching
template. First, the XSLT processor searches for a template that matches the first book
element. The template rule in the second template matches the book element:
<xsl:template match="book">
After instantiating this template for the first book element, the XSLT processor searches
for a template that matches the second book element. The XSLT processor instantiates the
book template again, and then repeats the process for the third book element. That is, the
XSLT processor searches for a matching template, and instantiates that template when it
is found.
After three instantiations of the book template, the XSLT processor returns to the first
template (the template that matches the root node) and continues with the line after the
xsl:apply-templates instruction.
384
The
xsl:apply-templates
expression.
The
xsl:template
pattern.
When the XSLT processor reaches an expression that is the value of a select attribute, it
evaluates the expression relative to the current node. The result of the evaluation is that
the XSLT processor selects a set of nodes to be processed.
When the XSLT processor reaches a pattern that is the value of a match attribute, it
evaluates the pattern alone. The result of the evaluation is that the XSLT processor
determines whether or not the pattern matches the node already selected for processing.
For example, suppose you have the following instruction:
<xsl:apply-templates select="/bookstore/book"/>
This instruction selects the book elements for processing. For each book element, the
XSLT processor searches for a template that matches the book element. The following
template matches the book element because the pattern identifies all elements that contain
author elements. Because book elements contain author elements, this template is a
match:
<xsl:template match="*[author]">
<td><xsl:value-of select="author"/></td>
</xsl:template>
This example shows that the expression that the XSLT processor uses to select nodes and
the pattern it uses to match nodes are independent of each other.
385
This section uses the sample stylesheet on Example of a Stylesheet on page 379 to
present this process in more detail in the following topics:
XSLT instructions
This template matches the root node. Consequently, the XSLT processor begins
processing by instantiating this template. This means it processes each part of the
template in the order in which it appears.
In the preceding example, the XSLT processor first copies the first four lines in the
template body directly into the result document. Then it executes the xsl:applytemplates instruction. When execution of that instruction is complete, the XSLT
386
processor continues processing this template with the last line in the template body. After
that, processing of this template is complete, and processing of the stylesheet is also
complete.
The value of the select attribute is an XPath expression. To evaluate this expression, the
XSLT processor uses the current source node as the initial context node. This is the node
for which the instruction that contains the select attribute is being executed. For example,
if this instruction is in the template that matches the root node, the root node is the current
source node.
or xsl:for-each instruction, the XSLT processor uses the
select expression you specify plus the current source node to select a set of nodes. By
default, the new list of source nodes is processed in document order. However, you can
use the xsl:sort instruction to specify that the selected nodes are to be processed in a
different order. See xsl:sort on page 496.
In an
xsl:apply-templates
387
The processor evaluates the expression specified for the xsl:apply-templates select
attribute to create a list of the source nodes identified by the expression.
2.
For each node in the list, the XSLT processor instantiates the best matching template.
(Template properties such as priority and mode allow multiple templates to match the
same node.)
3.
It is important to note that in step 2, the matching template might itself contain one or
more xsl:apply-templates instructions. As part of the instantiation of the matching
template, the XSLT processor searches for a template that matches the nodes identified by
the new xsl:apply-templates instruction. In this way, the XSLT processor can descend
many levels to complete processing of the first selected node in the initial xsl:applytemplates instruction. The xsl:apply-templates instruction allows you to access any
elements in the source document in any order.
Example
The sample template on Instantiating the First Template on page 386 contains the
following xsl:apply-templates instruction:
<xsl:apply-templates select="/bookstore/book"/>
The select attribute specifies "/bookstore/book" as the expression. This selects the set of
book elements in the source document as the nodes you want to process. For each selected
388
The XSLT processor searches the stylesheet for a template that matches "book".
When the XSLT processor finds the template that matches the book element, it
instantiates it. The following template matches the book elements selected by the
xsl:apply-templates instruction:
<xsl:template match="book">
<tr><td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td align="right"><xsl:value-of select="price"/></td></tr>
</xsl:template>
3.
The XSLT processor creates an HTML table row and executes the xsl:value-of
instructions. These instructions insert the values for the matching books title,
author, and price elements into the table.
The XSLT processor repeats this process for each book node. In other words, it instantiates
this template three times, once for each book element in the source document.
It is important to note that the XSLT processor does not search for a matching template
once and then instantiate that matching template for each selected element. Rather, the
XSLT processor performs the search for a matching template for each node selected for
processing. For each node selected for processing, the XSLT processor
389
However, the template that matches the book element does not specify any processing for
the published element. Consequently, the published elements do not appear in the result
document.
Priority Priority is a numeric value, such as 1, 10, or 99. The higher the numeric
value, the higher the templates priority. Priority is a useful way to distinguish the
relative importance of two templates.
Mode A templates mode allows you to define the context in which a given template
should be performed. To use the mode attribute, you specify it (mode=xyz, for
example) in both the xsl:template and xsl:apply-template instructions. Once you
have specified a mode, the processor applies a template only if the modes match.
Order If the XSLT processor cannot distinguish the best match among two or more
templates, it uses the last matching template that appears in the stylesheet. Thus, you
can enforce priority indirectly by the order in which you define the templates within
a stylesheet.
For information on specifying these attributes, see xsl:template on page 499 and
xsl:apply-templates on page 467.
The following template matches the root node and element nodes and selects all
attributes and child nodes for further processing:
<xsl:template match="*|/">
<xsl:apply-templates />
</xsl:template>
390
The following template matches text and attribute nodes. This template copies the
value of the text or attribute node to the result document:
<xsl:template match="@*|text()">
<xsl:value-of select="." />
</xsl:template>
Although Stylus Studio does not explicitly insert these templates in stylesheets you create
with Stylus Studio, they are always present. That is, as specified by the W3C XSLT
Recommendation, these templates are always defined, whether or not they are explicitly
defined. See Using Stylus Studio Default Templates on page 437.
XML
Well-formed XML.
HTML
Text
See xsl:output on page 490 for information about specifying formatting in a stylesheet.
391
This template creates many nodes in the result document that were not in the source
document.
You can also use XSLT instructions to create new nodes. Typically, you use XSLT
instructions when you need to compute the name or value of the node. You can find
information about using the following instructions in the XSLT Instructions Quick
Reference on page 465:
392
Given the current node, select the first matching source node.
393
Matches any book element that has a child that is a price element.
xsl:template match = "book [@price]"
Matches any book element that has a child that is a price element whose value is 14.
xsl:template match = "book [@price=14]"
Matches any book element that has a price attribute whose value is 14.
xsl:apply-templates select = "book"
Selects all book elements that are children of the current element.
xsl:apply-templates select = "book/price"
Selects all price elements that are children of book elements that are children of the
current element.
xsl:apply-templates select = "//book"
Selects all book elements that are descendants of the current element.
394
If you need to include a quoted string inside an attribute value (in a select expression, for
example), you can use the single quotation mark character (') in the value of the attribute.
For example:
select = "book[title = 'Trenton Today']".
The way xsl:for-each and xsl:apply-templates select nodes for processing is identical.
The way these instructions find the templates to process the selected nodes is different.
With xsl:for-each, the template to use is fixed. It is the template that is contained in the
body of the xsl:for-each element. With xsl:apply-templates, the XSLT processor finds
the template to be used for each selected node by matching that node against the template
rules in the stylesheet.
Finding a template by matching requires more time than using the contained template.
However, matching allows for more flexibility. Also, matching lets you avoid repeating
templates that might be used in more than one place in a stylesheet.
Named templates are another option for invoking a template from more than one place in
a stylesheet, when you know which template you want. It is a common mistake to use (and
bear the overhead of) matching when it is not needed. But it allows you to do powerful
things. Matching can take into account the following:
Template priority
Template ordering
Most complex document-formatting stylesheets use
xsl:apply-templates
extensively.
TIp Use the XSLT Profiler to help you understand where the processor is spending most of
395
If you want your result document to contain JavaScript commands, you must properly
escape the JavaScript code. Use the following format in your XSLT template:
<script>
<xsl:comment>
<![CDATA[ <your JavaScript here> ]]>
</xsl:comment>
</script>
However, this method does not work when your JavaScript section contains a block of
XSLT code. In this case, enclosing the JavaScript in a CDATA tag causes the XSLT
processor to ignore not just the JavaScript but also the markup code within that tag.
In this situation, enclose the entity reference within an <xsl:text> tag with disableto "yes". For example:
output-escaping set
You can use this wherever an entity reference needs to be handled specifically, as opposed
to being handled as part of an entire JavaScript section.
My browser does not understand the tag <br/>. How can I output just <br>?
Although your XSLT stylesheet must contain valid XML (meaning all tags must be either
empty or have a closing element), you can instruct the XSLT processor to generate output
compliant with HTML. See Deleting Templates on page 440.
Alternative: To ensure that your stylesheet always generates correct HTML, specify the
490.
xsl:output instruction with the method attribute set to html. See xsl:output on page
http://www.w3.org/Style/XSL/
http://www.w3.org/TR/xslt
396
397
Using this tree view, you can apply formatting to your XML double-clicking a node in
the tree automatically adds an xsl:template match= instruction for that node, for example.
Similarly, when you drag a node into the XSLT source, Stylus Studio displays a pop-up
menu that allows you to easily insert an XSLT instruction.
Figure 229. Stylus Studio Displays XSLT Instructions for Quick Editing
Finally, you can also use the tree to move quickly among different XSLT templates
clicking a node in the tree places the cursor at the corresponding template in the XSLT
source.
398
Sense:X technology automatically suggests XSLT or HTML tag and attribute names, and
ensures that all XML is well formed.
Sense:X also adapts to your document by suggesting more frequently used tags first. Valid
XSLT and HTML tag names are color coded to improve readability.
Trace the sequence of XSLT instructions that created HTML output. With a click
anywhere in the rendered HTML page, Stylus Studio Visual Backmapping
399
technology displays the XSLT instructions responsible for creating that portion of
HTML output.
Also, you can click in the stylesheet and the backmapping feature highlights the text
generated by that template.
Use the XSLT Profiling report to review performance metrics to help troubleshoot and
tune your XSLT stylesheets.
400
Editing the Template That Matches the Root Node on page 410
401
For a simpler tutorial that shows you how to define a stylesheet that generates a dynamic
Web page from a static HTML document, see Working with Stylesheets Getting
Started on page 33.
This tutorial duplicates some of the information in subsequent sections. For complete
information, see the following topics:
From the Stylus Studio menu bar, select File > New > XSLT Stylesheet.
Stylus Studio displays a new untitled stylesheet and the Scenario Properties dialog
box, and selects the text in the Scenario Name field.
Figure 232. Scenarios Let You Easily Test Different XSLT/XML Pairs
402
In the Scenario Properties dialog box, in the Scenario Name field, type
DynamicBookstoreScenario.
3.
Click Browse
to the right of the Source XML URL: field.
Stylus Studio displays the Open dialog box.
4.
5.
Double-click bookstore.xml. This is the XML document that the new stylesheet will
operate on.
6.
Figure 233. The XSLT Editor Shows XSLT Source on Left, Tree on Right
403
The default stylesheet that Stylus Studio creates contains one template, which
matches the root node.
404
7.
8.
9.
In the XSLT editor pane, click in the empty line that follows <xsl:template
match="/"> .
10.
11.
12.
Type />.
13.
14.
This time, the Preview window contains all text in bookstore.xml and none of the
markup. This is because the xsl:apply-templates instruction instantiates the default
templates.
To create a Web page, you need to add HTML markup that displays the information the
way you want. To make it easier to do that, you need to understand how the text is already
being copied to the result document.
405
After you complete the steps in the previous section, you can see the bookstore.xsl
stylesheet in the XSLT editor pane. It has the following contents:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
The stylesheet explicitly contains one template, which matches the root node. When the
XSLT processor applies a stylesheet, the first thing it does is search for a template that
matches the root node. If there is no template that explicitly matches the root node, the
XSLT processor uses a built-in template.
There are two built-in templates, also called default templates. Every XSLT stylesheet
contains these templates whether or not they are explicitly specified. This is part of the
W3C XSLT Recommendation.
This section discusses the following topics:
Instantiating the Template That Matches the Root Node on page 406
XML declaration
Comment
406
bookstore document
element
Unless you specify otherwise, the XSLT processor operates on the children in document
order. The first child is a processing instruction (the XML declaration). The XSLT
processor ignores processing instructions.
The second child is the comment node, and the XSLT processor also ignores comment
nodes.
The third child is the bookstore document element. The XSLT processor searches for a
template that matches bookstore. Because there is no template that explicitly matches the
bookstore element, the XSLT processor instantiates a built-in template that is not
explicitly in the stylesheet.
407
The XSLT processor operates on these children in document order. First, it searches for a
template that matches book. Because there is no template that explicitly matches the book
element, the XSLT processor instantiates the root/element default template for the first
book element.
Again, by default, the xsl:apply-templates instruction in the root/element default
template operates on the children of the current node in document order. That is, it
operates on the children of the first book element.
In the first book element, the first child is the title element. The XSLT processor searches
for a template that matches the title element. Because there is no template that explicitly
matches the title element, the XSLT processor instantiates the root/element default
template again.
At this point, the XSLT processor has initiated instantiation of the root template once, and
the root/element default template several times:
Instantiate root template for root node.
Instantiate root/element template for bookstore element.
Instantiate root/element template for first book element.
Instantiate root/element template for title in first book element.
It is important to understand that these instantiations are not yet complete. Each
subsequent instantiation of the root/element default template is inside the previous
instantiations.
408
The XSLT processor is finished with the title element, and it next processes the author
element in the first book element. There is no template that explicitly matches author, so
the XSLT processor instantiates the root/element default template. The first child of the
author element is the first-name element, and again, there is no template that explicitly
matches the first-name element. The XSLT processor instantiates the root/element
default template for the first-name element. The only child of the first-name element is
a text node. The XSLT processor instantiates the text/attribute default template for this
text node, and this template copies the text to the result document. Now the result
document contains the following text:
Seven Years in Trenton Joe
The XSLT processor is finished with the first-name element, and it next processes the
which is the second child of the author element.
last-name element,
409
And so on.
instructions. You can scroll the list and double-click the entry you want, or you can
continue typing. If you want, you can copy the text from here and paste it into the
Templates view.
<html>
<body>
<h3><center>Books in Stock</center></h3>
<table align="center" cellpadding="5">
<tr>
<th>Title</th>
<th>Author</th>
<th>Price</th>
</tr>
<xsl:apply-templates select="bookstore/book"/>
</table>
</body>
</html>
In the XSLT editor source document tree pane, expand the bookstore element.
2.
411
In the XSLT editor pane, add the following instructions to the new templates body:
<tr>
<td><xsl:apply-templates select="title"/></td>
<td><xsl:apply-templates select="author"/></td>
<td align="right">
<xsl:apply-templates select="price"/>
</td>
</tr>
Press F5 to see the results. The result document looks like that shown in Figure 236:
In the book template, the xsl:apply-templates instructions cause the XSLT processor to
instantiate the default templates. For the title and price elements, this works correctly
because those elements include only a text node. But for the author element, the use of
the default templates copies too much information to the result table. You need to
explicitly define a template for the author element.
412
1.
In the XSLT editor source document tree pane, expand the book element.
2.
In the XSLT editor pane view, edit the template body so that it contains only the
following contents.
<xsl:value-of select="first-name"/>
<xsl:value-of select="last-name"/>
If you do not include the nonbreaking space entity, the first name and the last name
have no space between them. Press F5 to see the results of this change, as shown in
Figure 237.
5.
Close the stylesheet by clicking File > Close on the Stylus Studio menu bar.
413
Also, Stylus Studio provides a number of tools that help you debug stylesheets. See
Debugging Stylesheets on page 551.
The XSLT Source, Mapper, and Params/Other tabs are always available.
Editing XSLT as XML
If you want, you can edit an XSLT file as an XML file. To do this, open the stylesheet in
the XML editor instead of in the XSLT editor. In the Open dialog box, click the down
arrow in the Open button. Click XML Editor in the drop-down menu. A document can be
open in the XML editor and in the XSLT editor at the same time.
414
Creating Stylesheets
To create a stylesheet:
1.
From the Stylus Studio menu bar, select File > New > XSLT Stylesheet.
Stylus Studio displays the Scenario Properties dialog box.
2.
In the Scenario Name: field, type a name for the association between the new
stylesheet and a particular XML source document. You might want to use the
convention of specifying the name you want your result document to have. The result
document is the document that will contain the result of applying the stylesheet you
are about to create.
3.
In the Source XML URL: field, type the name of an XML document or click Browse
to navigate to a document. Select a document you want to apply the new stylesheet
to. You are not limited to applying the new stylesheet to only this XML document.
You can create other scenarios later and specify other XML documents to which you
want to apply the same stylesheet.
4.
Click OK. Stylus Studio displays an untitled stylesheet window. The default text in the
new stylesheet appears in the left pane. The schema for the XML source document
you specified in the scenario properties appears in the right pane.
5.
6.
7.
8.
Click Save.
2.
415
Double-click HTML to XSLT (or select the HTML to XSLT icon and click OK).
The HTML to XML dialog box appears.
Enter the name of the HTML file you want to convert to XSLT in the Choose HTML
File to Convert to XSLT field.
5.
Click OK.
Stylus Studio opens the converted HTML file as an untitled XSLT file in the XSLT
Editor.
416
1.
Open the stylesheet for which you want to specify parameter values.
2.
Click the third field in the line that displays the parameter for which you want to
define a value Parameter value to be used when processing.
5.
6.
If you want Stylus Studio to pass this paramater as an XPath expression instead of as
a string, click the fourth field, which is a check box.
The default is that Stylus Studio passes a parameter as a string.
7.
Click OK.
417
In the XSLT Encoding field, you can specify the encoding you want Stylus Studio to use
when you save the stylesheet.
To display a list of the encodings supported by Stylus Studio, click the down arrow in the
XSLT Encoding field.
In the Output method field, you can specify the type of data you want the stylesheet to
generate. Choices include
xml
html Stylus Studio generates HTML that is compliant with HTML 4.0. This is
equivalent to inserting <xsl:output method="html"/> in a stylesheet.
text
unspecified
If you do not specify an xsl:output instruction in your stylesheet, Stylus Studio uses the
default output method you specify here. If you do specify an xsl:output instruction in
your stylesheet, that instruction overrides the default you specify here.
When the result of applying a stylesheet is XHTML, specify xml as the Output method.
Note, however, that Stylus Studio displays rendered HTML in the Preview in Browser
window.
In the Params/Other tab, in the Output Encoding field, you can specify the encoding you
want Stylus Studio to use in the document that is the result of applying the stylesheet.
When you apply a stylesheet, Stylus Studio uses this encoding for the output document.
418
You can change the encoding by changing the setting in the Params/Other tab or in the
initial processing instruction in the stylesheet. When you change the setting in one of
these places, Stylus Studio automatically changes it in the other. They are always the
same. In the Output Encoding field, click the down arrow to display a list of the supported
encodings.
If you want Stylus Studio to insert indents in the result document, select Indent.
Applying Stylesheets
In order to apply a stylesheet to an XML document, the stylesheet must be associated with
a scenario. See
419
Ensure that the correct output type is set. To do this, click the Params/Other tab at the
bottom of the stylesheet and check the value of the Output Method field.
If your stylesheet is associated with more than one scenario, select the scenario you want
to use and then apply the stylesheet. To do this, click the down arrow to the right of the
scenario name field to display a list of scenarios. Click the scenario you want to use, and
. After you apply a stylesheet in a particular scenario, the
then click Preview Result
Preview window displays a tab for that scenario. To reapply the stylesheet in that scenario,
click Preview Result
in the left tool bar.
You might want to apply the same stylesheet to two different XML documents and
compare the results. To do this, create a scenario for each XML source document. Apply
the stylesheet in the context of each scenario. Stylus Studio displays a tab for each
scenario at the bottom of the Preview window. Click the tab to display the result document
for that scenario.
Stylus Studio does not support scenarios that consecutively apply multiple stylesheets to
one source document.
420
If you click in the result document, Stylus Studio displays the Backmap Stack window,
which lists the XSLT instructions that generated the text you clicked.
Backmap Window
Stylus Studio also flags the line in the stylesheet that contains the first instruction in the
Backmap Stack window.
If the result document is XML, in the Preview window, you can click Preview in Tree
to display the result of XSLT processing as an XML tree.
Backmapping click on a result tree node and Stylus Studio displays the stylesheet
line that generated that node
To save the result of applying a stylesheet, click Save Preview
window. Stylus Studio displays the Save As dialog box.
in the Preview
421
The result document reflects any changes you made to either the XML source document
or the XSLT stylesheet. You do not need to explicitly save either the XML or XSLT file
to have changes to those documents appear in the result document. However, when you
apply a stylesheet, Stylus Studio does not also save the stylesheet. To save a stylesheet,
click Save
.
The source tree for the document the stylesheet will be applied to
If the source XML document is particularly large, loading it can take several minutes.
Each time you leave and return to Stylus Studio, Stylus Studio checks whether any open
documents have been modified. If the documents reside on remote servers, this can take
some time. If you want, you can turn off the check for modified documents.
To turn off the check for modified documents:
1.
2.
3.
Click the check box for Automatically check for externally modified files.
Creating a Scenario
A scenario allows you to preview the results of applying a stylesheet. Each scenario is for
a particular group of settings. These settings include the name of an XML source
document, the values of any parameters in the stylesheet, and the values of any encoding
settings. A scenario can include any setting that you can specify when you apply the
stylesheet.
A scenario can be associated with only one stylesheet and only one XML source
document. However, you can associate any number of scenarios with a stylesheet, and you
can associate any number of scenarios with an XML source document.
Tip If you start to create a scenario and then change your mind, click Delete and then OK.
422
2.
In the Scenario Name: field, type the name of the new scenario.
3.
In the Source XML URL: field, type the name of the XML file you want to apply the
stylesheet to, or click Browse
to navigate to an XML file and select it.
4.
In the Output URL field, optionally type or select the name of the result document you
want the stylesheet to generate. If you specify the name of a file that does not exist,
Stylus Studio creates it when you apply the stylesheet.
5.
In the Base URL For HTML Links Resolution field, optionally type the path for
resolving any links. For example, your stylesheet might have links to CSS stylesheets
or images.
6.
If you want Stylus Studio to Store paths relative to XSLT document path, ensure that
this option is checked.
7.
If you want to Preview result in an external application, ensure that this option is
checked. When this option is checked, Stylus Studio displays the result in the default
application for the output method specified for the scenario. For example, if the
output method for the scenario is HTML and if Internet Explorer is the default
application for displaying HTML files, Stylus Studio displays the resulting HTML in
Internet Explorer, as well as in the XSLT Preview window.
8.
If you want to specify values for stylesheet parameters, click the Parameter Values
tab. Double-click the Value field for the parameter you want to specify a value for.
9.
If you want to use an XSLT processor other than the Stylus Studio processor, click the
Processor tab and type the required information. See Using Third-Party XSLT
Processors on page 440.
10.
If you want to specify any post-processing, click the Post-process tab. See Postprocessing Result Documents on page 446.
11.
To define another scenario, click Add and enter the information for that scenario. You
can also copy scenarios. See Cloning Scenarios on page 424.
12.
Click OK.
423
Cloning Scenarios
When you clone a scenario, Stylus Studio creates a copy of the scenario except for the
scenario name. This allows you to make changes to one scenario and then run both to
compare the results.
Tip If you start to clone a scenario and then change your mind, click Delete and then OK.
To clone a scenario:
1.
2.
3.
In the Scenario Properties dialog box, in the Existing preview scenarios field, click
the name of the scenario you want to clone.
4.
Click Clone.
5.
In the Scenario name field, type the name of the new scenario.
6.
Change any other scenario properties you want to change. See Creating a Scenario
on page 422.
7.
Click OK.
In the stylesheet associated with the scenario, unless you turned off the Save scenario
meta-information in the stylesheet option.
In the project that the stylesheet belongs to, if the stylesheet belongs to a project.
When you save a stylesheet, Stylus Studio saves the scenario meta-information in the
stylesheet, but not in the project. When you select File > Save All or when you save the
project, Stylus Studio saves the scenario meta-information in the stylesheet and in the
project. To ensure that scenario meta-information in the project and in the stylesheet is
consistent
Ensure that you save the project after you modify scenario information. (If you close
a project without saving it, Stylus Studio prompts you to save it.)
424
Suppose you modify a scenario and save and close the associated stylesheet. If the
stylesheet belongs to the open project, when you save the project, Stylus Studio saves the
closed stylesheets scenario meta-information in the project.
In separate operations
In a single operation
Click the down arrow in the scenario field at the top of the stylesheet window.
2.
3.
Each time you generate a different scenario, Stylus Studio displays a tab at the bottom of
the Preview window for that scenario. Click the tab for the scenario you want to view. This
allows you to compare results.
425
The xsl:stylesheet instruction is required in every stylesheet that you use with Stylus
Studio.
Stylus Studio defines one template, which matches the root node. Of course, the two builtin templates are also defined, although they are not explicitly in the stylesheet. For
information about these templates, see Using Stylus Studio Default Templates on
page 437.
When Stylus Studio creates a stylesheet from an HTML file, the template that matches the
root node contains all HTML markup that was in the imported file.
426
To obtain the XPath expression that retrieves a particular node in the source document you
want to apply the stylesheet to, see Obtaining the XPath for a Node on page 160.
Updating Stylesheets
You can edit a stylesheet in the XSLT Source tab in Full Source
mode or Template
mode. To display a particular template in either mode, click the down arrow in the
upper right corner of the editing pane. This displays a drop-down list of template match
patterns. Click the template you want to view.
The XSLT editor keeps track of your XSLT context. That is, it keeps track of template
match patterns, and any xsl:for-each element that affects the context on which the
stylesheet is working. The editor uses Stylus Studios Sense:X technology to help you
create XPath expressions whenever they are needed.
After you associate the stylesheet with a scenario, you can display the source tree for the
XML source document specified in the scenario. Click Source Tree
in the XSLT
editor tool bar. This tree provides a description of the structure of the XML source
document specified in the scenario. This tree does not include elements and attributes that
are not instantiated in the particular source document. However, the tree provides a
structure that you can examine to help you understand stylesheet behavior in a given
scenario.
The following sections describe the Stylus Studio editing tools:
Dragging and Dropping from Schema Tree into XSLT Editor on page 427
xsl:for-each
xsl:value-of
xsl:apply-templates
node_name
427
Click the instruction you want to create. The XSLT context into which you drop the node
determines the value of the select attribute in the instruction you choose. The select
attribute always selects the node you dragged into the stylesheet. If you choose node_name,
Stylus Studio simply inserts the name of the element or attribute you dragged in. This is
convenient for pasting long element or attribute names.
If you drop the node in the stylesheet so that it is not in a template, Stylus Studio creates
a new template. In the new template, the value of the match attribute is the name of the
node you dragged into the stylesheet.
You can also create a new template by double-clicking a node in the source tree. The
difference between double-clicking a node and dragging a node is that when you doubleclick a node to create a template, Stylus Studio always inserts the template at the end of
the stylesheet. When you drag a node to create a template, you determine the location of
the template.
As you type in the XSLT edit window, Stylus Studio prompts you with a list of tag or
attribute names that match the first few letters you typed. To complete the tag name you
are typing, scroll the list if necessary, and double-click the tag you want.
You can customize the Sense:X system. Edit languages.xml in the Stylus Studio
bin\Plugins\Configuration Files directory to customize the tag list.
To set options that specify Sense:X behavior, go to the Editor General page of the Options
dialog box.
428
If you prefer, you can turn off this option. Then, when you start to type a closing tag, the
Sense:X list displays the only valid closing tag. Double-click it to insert it.
Ctrl+Z undoes the most recent action that has not already been undone.
Ctrl+Y redoes the most recently undone action that has not already been redone.
For additional shortcuts, see Keyboard Accelerators on page 1304.
Saving Stylesheets
When you save a stylesheet, Stylus Studio uses the encoding that is specified in the
Params/Other tab of the XSLT editor. You can change the encoding by changing the
setting in the Params/Other tab or in the initial processing instruction in the stylesheet.
When you change one of these, Stylus Studio automatically changes the other. They are
always the same.
To save an XSLT stylesheet, do one of the following:
Click Save
.
Press Ctrl+S.
Select File > Save from the Stylus Studio menu bar.
To save your stylesheet to another file, select File > Save As.
To save multiple files, select File > Save All. This saves all files that are open in Stylus
Studio.
Tip You can set an option that instructs Stylus Studio to save your modified documents every
few minutes. Go to the Applications Settings page on the Options dialog box.
429
430
First, you need to write a Java class that can be used from within a stylesheet. In this
example, the SystemDate() method returns the system date and time as a string:
import java.util.Date;
public class SystemUtils
{
public Object SystemDate()
{
Date d = new Date();
String s = d.toString();
return s;
}
}
2.
Second, compile your class and register it on the Stylus Studio host by copying the
.class file to a location defined in the hosts CLASSPATH environment variable.
3.
Finally, specify information in the stylesheet so that Stylus Studo can use your class.
You do this with a namespace reference in the xsl:stylesheet tag. For example,
define a namespace as xmlns:Ext where Ext is the prefix to use when calling the class
methods. (Ext is not a predefined keyword; it can be replaced by any other legal
string.) The namespace reference then takes the class name as a value. In this
example, the whole reference looks like the following:
xmlns:Ext="SystemUtils"
The class is now available from within the stylesheet and can be used in a template such
as the following:
<xsl:template match="NODE">
<p><xsl:value-of select="Ext:SystemDate()"/></p>
</xsl:template>
431
Java Type
Node Set
org.w3c.dom.NodeList
String
java.lang.String
Boolean
boolean or Boolean
Number
double or Double
org.w3c.dom.DocumentFragment
432
Object
Object
static
static
FxnName()
FxnName(Type1 var1, Type2 var2,...)
Object FxnName()
Object FxnName(Type1 var1, Type2 var2,...)
A class that contains an extension function might look like the following:
import org.w3c.dom.*;
import java.lang.Double;
public class NumberUtils
{
public Object Average(NodeList nl)
{
double nSum = 0;
for (int i = nl.getLength() - 1; i >= 0; i--)
{
nSum +=
Double.valueOf(nl.item(i).
getNodeValue()).doubleValue();
}
return new Double(nSum / nl.getLength());
}
}
xsl:stylesheet tag
Element that contains the XPath expression that invokes the extension function
Ancestor of the element that contains the XPath expression that invokes the extension
function
The XPath processor treats the namespace URI as a fully qualified class name. If the class
name is preceded by class:, all calls are to static methods only. Otherwise, an instance of
433
the class is created on first use and released when stylesheet processing is complete.
Performance is better when you use a static method because creation and deletion of an
instance of the class is not required.
You can separate package names with either a dot (.) or a forward slash (/). An sample
namespace declaration might look like the following:
<xsl:stylesheet xmlns:Ext="NumberUtils">
Saxon processor
434
The Saxon processor does not allow you to step into JavaScript extensions. You can step
into Java extensions, however.
Viewing Templates
Stylus Studio provides different ways to display lists of templates, specific templates, as
well as ways to see if a given template generates any output.
435
Click the down arrow in the upper right corner of the XSLT editing pane.
Stylus Studio displays a drop-down list of the first five match patterns in the
stylesheet. To limit the displayed list, type in the combo box to the left of the down
arrow. Stylus Studio displays only those patterns that match the character(s) you
typed.
A particular template might or might not have a match pattern (template rule). Named
templates do not necessarily specify match patterns.
Note
2.
Click the match pattern for the template you want to view. It does not matter whether
the XSLT editor is in Full Source
mode or Template
mode.
436
2.
Click Refresh
3.
In the XSLT Preview window, with output text displayed, scroll as necessary to find
text highlighted in gray. Text with a gray background was generated by the selected
template.
Every XSLT stylesheet contains these templates whether or not they are explicitly
specified. In other words, the XSLT processor behaves as if they are there even when they
are not explicitly specified in the stylesheet.
437
438
Creating Templates
To do anything beyond copying the text from your XML document to the result document,
you must create templates. You can create new templates several ways:
In the source tree of the XSLT editor, double-click the element or attribute for which
you want to create a template. Stylus Studio creates an empty template that matches
the node you clicked. This template appears at the end of the stylesheet.
Drag an element or node from the source tree in the XSLT editor to the Full Source
pane and drop it in a location that is not in a template. Stylus Studio creates a new
template that matches the node you dragged in.
Try creating a new template that matches an XML element in your document:
1.
2.
3.
4.
Press F5 to apply the stylesheet and refresh the current scenario in the Preview
window.
Notice that the text contents of the element for which you created the template are now
displayed in bold the XSL instruction is formatted with <b> and </b>. Also, the XSLT
processor does not process this element's children (if there are any) because the new
template you created does not specify <xsl:apply-templates/>.
By creating additional templates to style portions of your XML document, you can
completely control how the document appears.
Saving a Template
To save a template, save the stylesheet. Click Save
select File > Save from the Stylus Studio menu bar.
439
Applying Templates
The xsl:apply-templates instruction allows you to control the order of operations when
you apply a stylesheet. For an in-depth description of how the XSLT processor applies
templates, see How the XSLT Processor Applies a Stylesheet on page 385.
To apply a template so that you can see the output in the Preview window, you must apply
the entire stylesheet. Press F5 to apply the stylesheet and refresh the output. If Stylus
Studio detects any errors in the stylesheet or in the XML source document, it displays a
message that indicates the cause and location of the error.
In the Preview window, in the Text view, the text with a gray background was generated
by the template the cursor is in. If the editor is in Template mode, the text with the gray
background was generated by the currently visible template.
Updating Templates
When you want to update a template, you can use all features that are available when you
are updating a stylesheet. See Updating Stylesheets on page 427.
Deleting Templates
To delete a template:
1.
2.
3.
Click Cut.
Saxon 9.x
440
Back-mapping and debugging are not supported by other XSLT processors, including
others bundled with Stylus Studio (MSXML 4.0, for example).
Note You can use only the built-in XML parser with Stylus Studio.
2.
In the XSLT Editor, in the scenario name field, click the down arrow to display the
scenarios associated with the stylesheet.
3.
To use a third-party processor for an existing scenario, click the scenario name, and
then click
to display the Scenario Properties dialog box.
To create a new scenario, click Create Scenario. See Creating a Scenario on
page 422.
4.
In the Scenario Properties dialog box that appears, click the Processor tab.
5.
Select the XSLT processor you want to use from the Processor drop-down list.
Stylus Studio allow you to choose an MSXML option only if you have the MSXML
or MSXML .NET Framework (version 1.1 or 2.0) installed.
Note
6.
Optionally, change the default settings for the processor you selected.
7.
If you selected a standard XSLT processor, you are done. Click OK.
If you selected Use custom processor (%1 xml, %2 xslt, %3 output):
a.
In the Command line field, type the command line for invoking the processor you
want to run. You must specify the command line so that it is clear where to use
the three arguments. Following are two examples:
441
b.
In the Path field, specify any path that needs to be defined for the processor to
run. Typically, this is the location of the processor.
c.
In the Classpath field, type any directories the external processor needs to access
that are not already specified in your CLASSPATH environment variable.
d.
Click OK.
442
Complete the settings as desired. Press F1 to access the Stylus Studio online help, or
refer to the Saxon documentation for more information.
4.
Click OK.
Passing Parameters
To pass parameters to the Microsoft .NET, Saxon, or MSXML processor, specify them in
the Parameters tab of the Scenario Properties dialog box. To pass parameters to a custom
external processor, you must specify them in the command line you enter.
443
444
3.
Select the processor for which you want to specify default settings from the
Processor drop-down list.
4.
5.
If you want this processor to be used as the default processor for all XSLT scenarios,
click the Use as default processor check box.
6.
Click OK.
Stylus Studio built-in validator (Xerces C++). If you use the Stylus Studio built-in
validator, you can optionally specify one or more XML Schemas against which you
want the result document to be validated.
Any of the customizable processors supported by Stylus Studio, such as the .NET
XML Parser and XSV.
All validation is done before any post-processing that you might have specified.
To validate XSLT scenario result documents:
1.
2.
In the XSLT Editor (XSLT Source or Mapper tabs), in the scenario name field, click
the down arrow and click the name of the scenario for which you want to perform
validation.
3.
Click Browse
4.
445
If you are using Stylus Studios built-in validation engine, optionally, specify the
XML Schemas against which you want to validate the XML result document.
Otherwise, go to Step 7
a.
b.
c.
Click the Open button to add the XML Schema to the Validation tab.
d.
e.
Go to Step 8.
7.
Click the Use custom validator button, and select the validation engine you want to
use from the drop-down list box.
8.
Click OK.
446
1.
2.
In the XSLT Editor (XSLT Source or Mapper tabs), in the scenario name field, click
the down arrow and click the name of the scenario in which you want to specify postprocessing.
3.
Click Browse
4.
5.
In the Command line field, type the command line for starting your
postprocessor. For example, mypostprocessor %1 %2. You can specify any
application or script that takes as input the result document generated by an XSLT
processor and generates a new file.
b.
In the Generated File Extension field, type the extension on the file name of the
postprocessor output. For example, .pdf.
c.
In the Additional Path field, optionally type any paths that need to be defined that
are not already defined in your PATH environment variable.
d.
Click OK.
447
Note FO is a W3C recommendation for an XML vocabulary that describes how to format text.
FO is one part of XSL. This section assumes that you are familiar with FO. For additional
information about FO, see http://www.w3.org/TR/2001/REC-xsl-20011015/.
Define the scenario in which you want to apply the stylesheet that generates FO. See
Creating a Scenario on page 422.
2.
In the Scenario Properties dialog box, in the Post-process tab, do one of the
following:
3.
In the XSLT editor, define a stylesheet that generates FO. As soon as you type <fo:,
Stylus Studio displays a completion menu of FO that you can select from.
4.
2.
3.
4.
5.
6.
7.
VideoCenter\videos.xml
simpleMappings\books.xml
simpleMappings\catalog.xml
449
After a few seconds, the Preview window displays the PDF result in Acrobat Reader.
The result contains a few lines of text for each video and book found in the XML
source documents. The title, author or director, and the description is included for
each item. It is hard to see where information for one item ends and another begins.
450
3.
4.
This time the PDF result in the Preview window is nicely formatted. The catalog.xsl
stylesheet adds some basic formatting, as well as images, to the minimal-catalog.xsl
stylesheet. Now it is easy to distinguish the title, author or director, and description
for each video or book.
2.
Run a FOP, such as Apaches FOP, and use the generated XML as input.
Example
You can accomplish both steps with a single invocation of FOP on the command line. For
example:
java -cp "C:\Program Files\StylusStudio\bin\Plugins\Fop\fop.jar;"
org.apache.fop.apps.Fop -xml ..\VideoCenter\videos.xml -xsl
catalog.xsl -pdf multimediacatalog.pdf
451
Replace C:\Program
Studio is installed.
Files\StylusStudio with
Open the stylesheet whose results you want to postprocess with the Apache FOP.
2.
3.
4.
5.
Modify this sample command line according to where Stylus Studio is installed and
what kind of output you want the FOP to generate. The last option, -svg in the
example, can be any of the following:
Table 60. FOP Output Options
6.
452
Setting
Output
-mif
MIF file
-pcl
PCL file
-txt
Text file
-svg
-at
PDF file
In the Generated file extension field, specify the extension that indicates the type of
output you want. For example, specify .txt if you want the FOP to generate a text file.
If there is additional path information that the FOP will require to execute
successfully, type it in the Additional path field.
8.
Click OK.
graphics. It is assumed that you are familiar with SVG. For additional information about
SVG, see http://www.w3.org/Graphics/SVG.
453
The SalesFigures scenario has already been defined. In this scenario, the stylesheet
operates on elements in the chart.xml source document. This file is also in the
examples project, and in the examples\SVG directory.
2.
You can generate Java code for XSLT transformations in Stylus Studio. This section
describes the generated code, scenario settings that affect the generated code, as well as
procedures for generating, compiling, and running generated code.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Java Code Generation video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
This section covers the following topics:
454
Comment
General
The Code Generation wizard uses only the Source XML URL and the
Output URL field, if specified. All other properties on this page are
ignored.
Processor
You can use the following XSLT processors for generating Java code:
Saxon
Java built-in
Profiling Options
Ignored.
455
Comment
Validation
You can use the following validation engines for validating your XSLT Java
code:
Saxon
Java built-in
If you choose a validation engine that is not supported, Stylus Studio uses
the Java built-in validation engine.
Post-process
The target directory in which you want the Java code created. c:\temp\myJavaCode, for
example. If the directory you name does not exist, Stylus Studio creates it when you
run the Code Generation wizard.
456
The default is a \sources directory created in your Windows user data directory
C:\Documents and Settings\sula\My Documents\Stylus Studio\sources , for
example.
Optionally, a package name. If you specify a package name, this name is used for a
subfolder created in the target directory you specify. If you specify myPackage as the
package name, for example, the generated code is written to
c:\temp\myJavaCode\myPackage. (Though optional, it is considered good practice to
create a package name.)
The class name. Stylus Studio also uses the class name for the .java file created by
the Code Generation wizard. For example, if you provide the name myClass, Stylus
Studio creates c:\temp\myJavaCode\myPackage\myClass.java.
The default class name is taken from the XSLT file name.
Whether or not you want to add the generated code to the current Stylus Studio
project. If you choose to add the generated code to the project, it creates a folder using
the package name you specify and places the .java file in that folder. If you do not
specify a package name, the .java file is added directly below the project root in the
Project window.
Open the XSLT file for which you want to generate Java code.
2.
Define at least one scenario. The scenario must use the Saxon or Java built-in
processor. See Scenario Properties Used for Generating Code on page 455 for more
information.
3.
Select the scenario for which you want to generate Java code.
4.
5.
Select XSLT > Generate Code > Generate Java Code from the Stylus Studio menu.
The Generate Java Code dialog box appears. (See Figure 250 on page 456.)
6.
Specify the settings you want for the target directory, package and class names, and
so on. See Java Code Generation Settings if you need help with this step.
7.
Click OK.
457
Stylus Studio generates Java code for the XSLT. When the code generation is
complete, the resulting file (classname.java) is opened in the Stylus Studio Java
Editor.
458
2.
2.
459
Java code for XSLT. See Generating Java Code for XSLT
C# code for XQuery. See Generating C# Code for XQuery
460
The following tables summarizes the scenario properties that affect code generation.
Table 62. Scenario Properties that Affect Code Generation
Tab
Comment
General
The Code Generation wizard uses only the Source XML URL and the
Output URL field, if specified. All other properties on this page are
ignored.
Processor
You can use the following XSLT processors for generating Java code:
Microsoft XslCompiledTransform
Saxon
Profiling Options
Ignored.
Validation
You can use the following validation engines for validating your XSLT C#
code:
Saxon
If you choose a validation engine that is not supported, Stylus Studio uses
the .NET XML parser.
Post-process
461
The target directory in which you want the C# code created. c:\temp\myC#Code, for
example. If the directory you name does not exist, Stylus Studio creates it when you
run the Code Generation wizard.
The default is a \sources directory created in your Windows user data directory
C:\Documents and Settings\sula\My Documents\Stylus Studio\sources , for
example.
Optionally, a namespace name. If you specify a namespace name, this name is used
for a subfolder created in the target directory you specify. If you specify
myNamespace as the package name, for example, the generated code is written to
c:\temp\myC#Code\myNamespace. (Though optional, it is considered good practice to
create a namespace name.)
462
The class name. Stylus Studio also uses the class name for the .cs file created by the
Code Generation wizard. For example, if you provide the name myClass, Stylus
Studio creates c:\temp\myC#Code\myNamespace\myClass.cs.
the default class name.
The location of Saxon .NET on your system. Stylus Studio adds this URL to the
Microsoft Visual Studio 2005 project, allowing the generated C# code for .NET to
compile.
Whether or not you want the resulting .cs file to contain a static void Main(String
[ ] args) method.
Whether or not you want to open the generated code in a third-party development
tool, like Microsoft Visual Studio, for example.
Whether or not you want add the class to a new Visual Studio 2005 project or update
an existing one. If a new project is created, it is automatically opened with whatever
application is registered to open .csproj files. The .csproj file contains all the
necessary references to the generated .cs file, as well as all the .dll files that the .cs
file requires.
To run the .cs file, simply press Ctrl+F5 in Visual Studio.
2.
Define at least one scenario for the XSLT transformation. The scenario must use the
Saxon processor. See Scenario Properties Used for Generating Code for more
information.
3.
4.
5.
Select XSLT > Generate Code > Generate C# Code from the Stylus Studio menu.
The Generate C# Code dialog box appears. (See Figure 251 on page 462.)
6.
Specify the settings you want for the target directory, package and class names, and
so on. See C# Code Generation Settings if you need help with this step.
7.
Click OK.
463
Stylus Studio generates C# code for the XSLT. When the code generation is complete,
the resulting file (classname.cs) is opened in a third-party editor if you chose the
Open the generated file option.
464
465
466
xsl:apply-imports
Invokes overridden template rules.
Stylus Studio does not support the xsl:apply-imports instruction.
xsl:apply-templates
Selects source nodes for processing.
Format
<xsl:apply-templates [select="pattern"][mode="qname"]>
[<xsl:sort/>]
[<xsl:with-param/>
</xsl:apply-templates>
Description
If you specify the select attribute, specify a pattern that resolves to a set of source nodes.
For each source node in this set, the XSLT processor searches for a template that matches
the node. When it finds a matching template, it instantiates it and uses the node as the
context node. For example:
<xsl:apply-templates select="/bookstore/book">
When the XSLT processor executes this instruction, it constructs a list of all nodes that
match the pattern in the select attribute. For each node in the list, the XSLT processor
searches for the template whose match pattern best matches that node.
If you do not specify the select attribute, the XSLT processor uses the default pattern,
"node()", which selects all child nodes of the current node.
If you specify the mode attribute, the selected nodes are matched only by templates with a
matching mode attribute. The value of mode must be a qualified name or an asterisk (*). If
you specify an asterisk, it means continue the current mode, if any, of the current template.
If you do not specify a mode attribute, the selected nodes are matched only by templates
that do not specify a mode attribute
By default, the new list of source nodes is processed in document order. However, you can
use the xsl:sort instruction to specify that the selected nodes are to be processed in a
different order. See xsl:sort on page 496.
Tip You can create an xsl:apply-templates element automatically using the XSLT mapper.
467
Example
In the previous example, the XSLT processor searches for a template that matches
/bookstore/book. The following template is a match:
<xsl:template match="book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/><td>
<td><xsl:value-of select="price"/><td>
</tr>
</xsl:template>
The XSLT processor instantiates this template for each book element.
xsl:attribute
Creates an attribute.
Format
<xsl:attribute name="qualified_name">
attribute_value
</xsl:attribute>
Description
You can specify the xsl:attribute instruction in the
468
If you add an attribute to an element and that element already has an attribute with the
same expanded name, the attribute you are creating replaces the existing attribute.
Example
<xsl:attribute name="library:ISBN"
namespace="http://www.library.org/namespaces/library">
1-2222-333-4
</xsl:attribute>
If this instruction is inside a book element, the resulting book element would include the
following attribute:
library:ISBN="1-22222-333-4"
The XSLT processor reports an error if you try to do any of the following:
Create anything other than characters during instantiation of the contents of the
xsl:attribute element.
xsl:attribute-set
Defines a named set of attributes.
Format
<xsl:attribute-set name="set_name">
<xsl:attribute name="attr_name">attr_value</xsl:attribute>
<xsl:attribute name="attr_name">attr_value</xsl:attribute>
...
</xsl:attribute-set>
Description
The name attribute specifies the name of the attribute set. This must be a qualified name.
The contents of the xsl:attribute-set element consists of zero or more xsl:attribute
elements. Each xsl:attribute element specifies an attribute in the set.
To use an attribute set, specify the use-attribute-sets attribute in one of the following
elements:
xsl:element
xsl:copy
469
xsl:attribute-set
470
Example
The following example creates a named attribute set, title-style, and uses it in a
template rule:
<xsl:template match="chapter/heading">
<fo:block quadding="start" xsl:use-attribute-sets="title-style">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:attribute-set name="title-style">
<xsl:attribute name="font-size">12pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
xsl:call-template
Instantiates a named template.
Format
<xsl:call-template name="template_name">
[<xsl:with-param/>]
</xsl:apply-templates>
Description
The name attribute is required and the value must be a qualified name. It specifies the name
of the template you want to instantiate. The template you want to instantiate must specify
the name attribute with a value identical to template_name.
Unlike the xsl:apply-templates instruction, the xsl:call-template instruction does not
change the current node.
Tip You can create an xsl:call-template element automatically using the XSLT mapper.
xsl:character-map
Declares a character map defined by a unique name. A stylesheet cannot contain two or
more character maps with the same name. Character maps are supported by XSLT 2.0
only.
Tip Character maps are an alternative to defining character entities using a DTD, which was
471
Format
<xsl:character-map
name = qname
[use-character-maps = qnames]>
[<xsl:output-character> ...]
</xsl:character-map>
Description
A character map allows a specific character appearing in a text or attribute node in the
final result tree to be substituted by a specified string of characters during serialization.
The character map that is supplied as a parameter to the serializer is determined from the
xsl:character-map elements referenced from the xsl:output declaration for the selected
output definition.
Character/string mappings can be defined in the body of the xsl:character-map element
using one or more xsl:output-character elements, or they can be defined in an external
character map referenced using the optional use-character-maps attribute. If the character
map references multiple external character maps, separate each character maps Qname
with a space.
An output definition, after recursive expansion of character maps referenced via its usecharacter-maps attribute, may contain several mappings for the same character. In this
situation, the last character mapping takes precedence.
If a character is mapped, it is not subjected to XML or HTML escaping.
472
Example
This example shows a composite character map one constructed using both internally
defined character mappings (xsl:output-character), and references to externally defined
character maps (the use-character-maps attribute):
<xsl:output name="htmlDoc" use-character-maps="htmlDoc" />
<xsl:character-map name="htmlDoc"
use-character-maps="html-chars doc-entities windows-format" />
<xsl:character-map name="html-chars"
use-character-maps="latin1 ..." />
<xsl:character-map name="latin1">
<xsl:output-character character=" " string="&nbsp;" />
<xsl:output-character character="¡" string="&iexcl;" />
...
</xsl:character-map>
<xsl:character-map name="doc-entities">
<xsl:output-character character="" string="&t-and-c;" />
<xsl:output-character character="" string="&chap1;" />
<xsl:output-character character="" string="&chap2;" />
...
</xsl:character-map>
<xsl:character-map name="windows-format">
<!-- newlines as CRLF -->
<xsl:output-character character="
" string="
" />
<!-- tabs as three spaces -->
<xsl:output-character character="	" string="
" />
473
xsl:choose
Selects one template to instantiate from a group of templates.
Format
<xsl:choose>
<xsl:when test="expression1">
template_body
</xsl:when>
[<xsl:when test="expression2">
template_body
</xsl:when>] ...
[<xsl:otherwise>
template_body
</xsl:otherwise>]
</xsl:choose>
Description
An
When the XSLT processor processes an xsl:choose element, it starts by evaluating the
expression in the first xsl:when element. The XSLT processor converts the result to a
Boolean value. If the result is true, the XSLT processor instantiates the template
contained by that xsl:when element. If the result is false, the XSLT processor evaluates
the expression in the next xsl:when element.
The XSLT processor instantiates the template of only the first xsl:when element whose
test expression evaluates to true. If no expressions evaluate to true and there is an
xsl:otherwise element, the XSLT processor instantiates the template in the
xsl:otherwise element.
If no expressions in xsl:when elements are true and there is no xsl:otherwise element,
the xsl:choose element has no effect.
Tip You can create an xsl:choose element automatically using the XSLT mapper.
474
xsl:comment
Adds a comment node to the result tree.
Format
<xsl:comment>
comment_text
</xsl:comment>
Description
The XSLT processor instantiates the contents of the instruction to generate the text of the
new comment.
The XSLT processor reports an error if instantiating the contents of the xsl:comment
instruction creates anything other than characters, or if the resulting string contains the
substring "--" or ends with "-".
Example
The following instruction creates a comment in the result document:
<xsl:comment>Unique Irish band</xsl:comment>
The comment is
<!--Unique Irish band-->
xsl:copy
Adds a copy of the current node to the result tree.
Format
<xsl:copy>copy_contents</xsl:copy>
Description
The copy includes the current nodes namespace information but does not include the
current nodes attributes or children. The contents of the xsl:copy element is a template
for the attributes and children of the node being created. If the current node cannot have
475
Example
Following is an example from the W3C XSLT Recommendation. It generates a copy of
the source document.
<xsl:template match="@* | node() ">
<xsl:copy>
<xsl:apply-templates select="@* | node() " />
</xsl:copy>
</xsl:template>
xsl:copy-of
Inserts the value of an expression into the result tree, without first converting it to a string.
Format
<xsl:copy-of select = "expression" />
Description
The required select attribute contains an expression. When the result of evaluating the
expression is a result tree fragment, the XSLT processor copies the complete fragment
into the result tree. When the result is a node set, the XSLT processor copies all nodes in
the set, together with their contents, in document order into the result tree. When the result
is of any other type, the XSLT processor converts the result to a string and then inserts the
string into the result tree in the same way that xsl:value-of does.
Tip You can also use xsl:sequence to add atomic values to a sequence. See xsl:sequence on
476
xsl:decimal-format
Declares a decimal format.
Format
<xsl:decimal-format
name = qname
decimal-separator = char
grouping-separator = char
infinity = string
minus-sign = char
NaN = string
percent = char
per-mille = char
zero-digit = char
digit = char
pattern-separator = char />
Description
The xsl:decimal-format instruction declares a decimal format, which controls the
interpretation of a format pattern that is used by the format-number() function.
If there is a name attribute, the element declares a named decimal format. Otherwise, it
declares the default decimal format. The value of the name attribute is a qualified name.
The other attributes on xsl:decimal-format correspond to the methods on the JDK
DecimalFormatSymbols class. For each get/set method pair, there is an attribute defined for
decimal-separator specifies the character used for the decimal sign; the default value
is the dot character (.).
percent specifies the character used as a percent sign; the default value is the percent
character (%).
per-mille specifies the character used as a per mille sign; the default value is the
Unicode per mille character (#x2030).
zero-digit specifies the character used as the digit zero; the default value is the digit
zero (0).
The following attributes control the interpretation of characters in the format pattern:
Stylus Studio User Guide
477
digit specifies the character used for a digit in the format pattern; the default value is
The following attributes specify characters or strings that can appear in the result of
formatting the number:
infinity specifies the string used to represent infinity; the default value is the string
"Infinity".
minus-sign specifies the character used as the default minus sign; the default value is
the hyphen (minus) character (-, #x2D).
NaN specifies the string used to represent the NaN value; the default value is the string
"NaN".
xsl:element
Adds an element to the result tree.
Format
<xsl:element name="qualified_name">
element_contents
</xsl:element>
Description
The XSLT processor uses the contents of the xsl:element instruction as a template for the
attributes and contents of the new element.
The prefix part of the name attribute becomes the prefix for the element you are creating.
The local part of the name attribute becomes the local name of the element you are
creating.
The XSLT processor interprets the name attribute as an attribute value template. The string
that results from instantiating the attribute value template must be a qualified name. If it
is not, the XSLT processor reports an error.
478
Example
<xsl:element name="audio:CD">
<xsl:element name="audio:title">Celtic Airs</xsl:element>
<xsl:element name="audio:artist">Chieftains</xsl:element>
</xsl:element>
xsl:fallback
Normally, instantiating an xsl:fallback element does nothing. However, when an XSLT
processor performs fallback for an instruction element, if the instruction element has one
or more xsl:fallback children, then the content of each of the xsl:fallback children must
be instantiated in sequence; otherwise, an error is signaled. The content of an
xsl:fallback element is a template.
xsl:for-each
Selects a set of nodes in the source document and instantiates the contained template once
for each node in the set.
Format
<xsl:for-each select="pattern">
[<xsl:sort[select="expression"][optional_attribute]/>]
template_body
</xsl:for-each>
Description
The select attribute is required and the pattern must evaluate to a node set. The XSLT
processor instantiates the embedded template with the selected node as the current node
and with a list of all selected nodes as the current node list.
By default, the new list of source nodes is processed in document order. However, you can
use the xsl:sort instruction to specify that the selected nodes are to be processed in a
different order. See xsl:sort on page 496.
479
The xsl:for-each instruction is useful when the result document has a regular, known
structure. When you know that you want to instantiate the same template for each node in
the current node list, the xsl:for-each instruction eliminates the need to find a template
that matches each node.
Tip You can create an xsl:for-each element automatically using the XSLT mapper.
Example
For example, suppose your source document includes the following XML:
<books>
<author>
<name>Sara Peretsky</name>
<booktitle>Bitter Medicine</booktitle>
<booktitle>Killing Orders</booktitle>
</author>
<author>
<name>Dick Francis</name>
<booktitle>Reflex</booktitle>
<booktitle>Proof</booktitle>
<booktitle>Nerve</booktitle>
</author>
</books>
The following stylesheet creates an HTML document that contains a list of authors. Each
author is followed by the titles of the books the author wrote. It does not matter how many
authors there are nor how many titles are associated with each author. The stylesheet uses
the xsl:for-each instruction to process each author and to process each title associated
with each author.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match = "/">
<html>
<head><title>Authors and Their Books</title></head>
<body>
<xsl:for-each select = "books/author">
<p>
<xsl:value-of select = "name"/>
<br>
<xsl:for-each select = "booktitle">
<xsl:value-of select = "."/>
<br>
</xsl:for-each>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
480
xsl:for-each-group
Allocates the items in an input sequence into groups of items (that is, it establishes a
collection of sequences) based either on common values of a grouping key, or on a pattern
that the initial or final node in a group must match.
Format
<xsl:for-each-group
select = expression
[group-by = expression]
[group-adjacent = expression]
[group-starting-with = pattern]
[group-ending-with = pattern]
[collation = { uri }>
<!-- Content: (xsl:sort*, sequence-constructor) -->
</xsl:for-each-group>
Description
The xsl:for-each-group element is an instruction that can be used anywhere within a
sequence constructor. The sequence of items to be grouped is referred to as a population.
A group cannot be empty. If the population is zero (that is, empty), the number of groups
is zero. How items are assigned to groups is determined by the group-by, group-adjacent,
group-starting-with, and group-ending-with attributes.
481
xsl:function
Allows the creation of user-defined stylesheet function that can be called from any XPath
expression within the stylesheet in which the function is defined. This instruction is
supported in XSLT 2.0 only.
Format
<xsl:function name=Qname" as=sequence type [override=yes | no]>
function_body
</xsl:function>
Description
The value of the name attribute, Qname, is a qualified name and takes the form prefix:name.
The prefix is required in order to avoid possible conflicts with any functions in the default
function namespace. The prefix cannot refer to a reserved namespace.
The function_body contains zero or more xsl:param elements that specify the formal
arguments of the function. These xsl:param elements are followed by a sequence
constructor that defnes the value to be returned by the function. The xsl:param elements
within an xsl:function element must be empty; they cannot have a select attribute
because they must be specified.
An xsl:function declaration can only appear as a top-level element in a stylesheet.
482
Example
Here is an example from the W3C XSLT Working Draft of a simple function that reverses
the order of the words in a sentence.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:str="http://example.com/namespace"
version="2.0"
exclude-result-prefixes="str">
<xsl:function name="str:reverse" as="xs:string">
<xsl:param name="sentence" as="xs:string"/>
<xsl:sequence
select="if (contains($sentence, ' '))
then concat(str:reverse(substring-after($sentence, ' ')),
' ',
substring-before($sentence, ' '))
else $sentence"/>
</xsl:function>
<xsl:template match="/">
<output>
<xsl:value-of select="str:reverse('DOG BITES MAN')"/>
</output>
</xsl:template>
</xsl:transform>
xsl:if
Conditionally instantiates the contained template body.
Format
<xsl:if test = "expression">
template_body
</xsl:if>
Description
The XSLT processor evaluates the expression and converts the result to a Boolean value.
If the result is true, the XSLT processor instantiates template_body. If the result is false,
the xsl:if element has no effect.
483
Example
This following example formats a group of names as a comma-separated list:
<xsl:template match="namelist/name">
<xsl:value-of select="." />
<xsl:if test="not(position()=last())">, </xsl:if>
</xsl:template>
If you want the XSLT processor to choose which template to instantiate from several
possibilities, specify the xsl:choose instruction. See xsl:choose on page 474.
xsl:import
Imports a stylesheet into the stylesheet containing this instruction.
Format
<xsl:import href="stylesheet_path">
stylesheet_path specifies
Description
An XSLT stylesheet can import another XSLT stylesheet by using an xsl:import
instruction. Importing a stylesheet is the same as including it, except that definitions and
template rules in the importing stylesheet take precedence over template rules and
definitions in the imported stylesheet.
The xsl:import element is only allowed as a top-level element. The xsl:import element
children must precede all other element children of an xsl:stylesheet element, including
any xsl:include element children. When xsl:include is used to include a stylesheet, any
xsl:import elements in the included document are moved up in the including document
to after any existing xsl:import elements in the including document.
When you use the xsl:import instruction, templates have an importance property.
xsl:import-schema
Identifies schema components (top-level type definitions and top-level element and
attribute declarations) that need to be available statically, that is, before any source
484
document is available. Allows you to extend XSLT built-in types with the types defined
in the imported XML Schema.
Format
<xsl:import-schema
namespace = uri-reference
schema-location = uri-reference>
<!-- Content: xs:schema -->
</xsl:import-schema>
Description
The xsl:import-schema declaration identifies a namespace containing the names of the
components to be imported (or indicates that components whose names are in no
namespace are to be imported). The effect is that the names of top-level element and
attribute declarations and type definitions from this namespace (or non-namespace)
become available for use within XPath expressions in the stylesheet, and within other
stylesheet constructs such as the type and as attributes of various XSLT elements.
The same schema components are available in all stylesheet modules; importing
components in one stylesheet module makes them available throughout the stylesheet.
The namespace and schema-location elements are optional. The namespace attribute
indicates that a schema for the given namespace is required by the stylesheet. This
information may be enough on its own to enable an implementation to locate the required
schema components. The namespace attribute may be omitted to indicate that a schema for
names in no namespace is being imported. The zero-length string is not a valid namespace
URI, and is therefore not a valid value for the namespace attribute.
The schema-location attribute is a URI Reference that describes where a schema
document or other resource containing the required definitions may be found. It is likely
that a schema-aware XSLT processor will be able to process a schema document found at
this location.
The use of a namespace in an xsl:import-schema declaration does not by itself associate
any namespace prefix with the namespace. If names from the namespace are used within
the stylesheet module then a namespace declaration must be included in the stylesheet
module, in the usual way.
You can also define an inline schema document using the xs:schema element as a child of
xsl:import-schema. An inline schema document has the same status as an external schema
document, in the sense that it acts as a hint for a source of schema components in the
485
relevant namespace. To ensure that the inline schema document is always used, it is
advisable to use a target namespace that is unique to this schema document.
Example
The following example shows an inline schema document defined using the xs:schema
subelement. This schema declares a simple type local:yes-no, which the stylesheet then
uses in the declaration of a variable. The example assumes the namespace declaration
xmlns:local="http://localhost/ns/yes-no".
<xsl:import-schema>
<xs:schema targetNamespace="http://localhost/ns/yes-no">
<xs:simpleType name="local:yes-no">
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
</xs:import-schema>
<xs:variable name="condition" select="'yes'" as="local:yes-no"/>
xsl:include
Specifies an XSLT stylesheet that is included in and combined with the stylesheet that
specifies xsl:include.
Format
<xsl:include href="stylesheet_path">
Description
The xsl:include instruction must be a child of an xsl:stylesheet element. The XSLT
processor effectively replaces the xsl:include instruction with the children of the root
xsl:stylesheet element of the included stylesheet. If the root element of the included
stylesheet is a literal result element, the XSLT processor effectively replaces the
xsl:include instruction with the following new element whose only child is that literal
result element:
<xsl:template match="/">
486
xsl:key
Declares a key for a document.
Format
<xsl:key name="qname"
match = "pattern"
use = "use" />
Description
Keys provide a way to work with documents that contain an implicit cross-reference
structure. A stylesheet declares a key for a document with the xsl:key instruction.
The xsl:key instruction must be a top-level element. It has no contents, but it specifies
three attributes.
Replace qname with the name of the key. You must specify a qualified name.
Replace pattern with a pattern that identifies one or more nodes that have this key. In
other words, the nodes in the document that match the pattern are included in the key. The
default is node().
Replace use with an expression that you want to use for the key values. The XSLT
processor evaluates the expression once for each node in the set identified by pattern.
Each key name represents a separate, independent set of identifiers. Each node included
in a key is associated with a set of string key values. These values result from evaluating
the use expression with that node as the current node.
A document can contain multiple keys with the same node and the same key name, but
with different key values. A document can contain multiple keys with the same key name
and value, but with different nodes. In other words:
For a given key, a key value can be associated with more than one node.
The same key value can be associated with different nodes in different keys.
The value of a key can be an arbitrary string. It need not be a name.
Use the XSLT key() function to retrieve the list of nodes included in a given key that have
given key values. See Finding an Element with a Particular Key on page 767.
You cannot specify multiple declarations for the same key in a stylesheet. Stylus Studio
expects to remove this restriction in a future release.
Stylus Studio User Guide
487
xsl:message
Sends a message in a way that is dependent on the XSLT processor.
Format
<xsl:message terminate="yes" | "no">
<!-- Content: template -->
</xsl:message>
Description
The content of the xsl:message instruction is a template. If the value of the terminate
attribute is yes, the XSLT processor instantiates the template to create text. The processor
aborts stylesheet processing and sends the text as part of the error message that indicates
that stylesheet processing has terminated.
The default value of the terminate attribute is no. If you specify terminate="no" or if you
do not specify the terminate attribute,
488
xsl:namespace-alias
Causes the namespace URI to be changed in the output.
Format
<xsl:namespace-alias
stylesheet-prefix = prefix | "#default"
result-prefix = prefix | "#default" />
Description
Declares that one namespace URI is an alias for another namespace URI. When a literal
namespace URI has been declared to be an alias for another namespace URI, then the
namespace URI in the result tree is the namespace URI that the literal namespace URI is
an alias for, instead of the literal namespace URI itself.
xsl:number
Inserts a formatted number into the result tree.
Format
<xsl:number
[level = "single" | "multiple" | "any"]
[count = pattern]
[from = pattern]
[value = number-expression]
[format = {string}]
[lang = {nmtoken}]
[letter-value = {"alphabetic" | "traditional"}]
[grouping-separator = {char}]
[grouping-size = {number}]/>
Description
You can use the value attribute to specify an expression for the number to be inserted. The
XSLT processor evaluates the expression. The resulting object is converted to a number
as if by a call to the number() function. The processor rounds the number to an integer and
then uses the specified attributes to convert it to a string. The value of each attribute is
interpreted as an attribute value template. After conversion, the resulting string is inserted
in the result tree.
The following attributes control how the current node is to be numbered:
489
The level attribute specifies what levels of the source tree should be considered. The
default is single.
The count attribute is a pattern that specifies what nodes should be counted at those
levels.
The from attribute is a pattern that specifies where counting starts.
The value attribute can specify an expression that represents the number you want to
insert. If no value attribute is specified, the XSLT processor inserts a number based
on the position of the current node in the source tree.
The format attribute specifies the format for each number in the list. The default is 1.
The lang attribute specifies which languages alphabet is to be used.
The letter-value attribute distinguishes between the numbering sequences that use
letters.
The grouping-separator attribute specifies the separator used as a grouping (for
example, thousands) separator in decimal numbering sequences.
The grouping-size attribute specifies the size of the grouping. Normally, this is 3.
Example
The following example numbers a sorted list:
<xsl:template match="items">
<xsl:for-each select="item">
<xsl:sort select="."/>
<p>
<xsl:number value="position()" format="1. "/>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
</xsl:template>
xsl:otherwise
See xsl:choose on page 474.
xsl:output
Specifies the output for the result tree.
Format
<xsl:output attribute_list />
490
Description
The xsl:output instruction specifies how you want the result tree to be output. However,
if you use the XSLT processor to format the result as a string, or to generate DOM nodes,
the xsl:output instruction has no effect.
If you specify the xsl:output instruction, the XSLT processor outputs the result tree
according to your specification. If you specify it, the xsl:output instruction must be a
top-level element.
The attribute list can include the method attribute. The method attribute identifies the
overall method you want the XSLT processor to use to output the result tree. The value
must be xml, html, or text.
html formats the result tree as HTML. The stylesheet applies special formatting rules
for empty tags, binary attributes, and character escaping, among other things. The
values of the attributes named href and src are URL encoded.
text concatenates the text nodes in the result tree. The concatenated string does not
include any tags.
Note that the XSLT processor formats the results of applying the stylesheet. If your
stylesheet generates XML or HTML that does not follow all syntax rules, the XSLT
processor does not do anything to fix this. For example, if a stylesheet generates multiple
root elements, the XSLT processor neither fixes this nor generates an error. You receive a
string, and it is only upon examination or use of the string that you would learn that it is
not well-formed XML.
If you do not specify an xsl:output instruction that includes the method attribute, the
XSLT processor chooses a default as follows:
html is the default output method if the name of the first element child of the root node
is html.
text is the default output method if the root node has no element child nodes.
491
encoding specifies
If the output method is html, the XSLT processor does not insert an XML
declaration.
If the output method is xml, the XSLT processor inserts an XML declaration.
The XSLT processor ignores this attribute when the output method is text.
standalone specifies whether the XSLT processor should output a stand-alone
document declaration. The value must be yes or no.
use-character-map specifies the name, if any, of the character map you want to use
for the output. A character map substitutes characters based on character/string
mappings declared in the xsl:character-map element.
A stylesheet can include multiple xsl:output elements. The XSLT processor effectively
merges multiple xsl:output elements into one xsl:output element. If there are multiple
values for the same attribute, the XSLT processor uses the last specified value.
In this release, the XSLT processor ignores the following attributes:
492
xsl:output-character
Declares character/string mappings used by the xsl:character-map declaration.
xsl:output-character is supported in XSLT 2.0 only.
Format
<xsl:output-character
character = char
string = string />
Description
The character map that is passed as a parameter to the serializer contains a mapping for
the character specified in the character attribute to the string specified in the string
attribute.
Example
See xsl:character-map on page 471.
xsl:param
Declares a parameter for a stylesheet or template, and specifies a default value for the
parameter.
Format
<xsl:param name="parameter_name"
[select = "expression1"]
[expr = "expression2"]>
[template_body]
</xsl:param>
Description
The xsl:param instruction declares a parameter and specifies its default value. Another
value can be passed to this parameter when the template or stylesheet that contains this
xsl:param instruction is invoked.
The xsl:param element must be a child of either an xsl:stylesheet or
element.
xsl:template
493
The name attribute is required, and it must be a string. The value of the name attribute is a
qualified name.
The value that you bind to a parameter can be an object of any of the types that are
returned by expressions. You can specify the value of the parameter in several ways:
Specify the select attribute. The value of the select attribute must be an expression.
The XSLT processor evaluates the expression, and the result is the default value of the
parameter. If you specify the select attribute, the XSLT processor ignores any value
you might specify for the expr attribute, and also ignores any contents of xsl:param.
Specify the expr attribute. The expr attribute allows computation of an expression.
For example:
<xsl:param name="query" expr="//VEHICLE[MAKE='{$make}']"/>
The XSLT processor interprets the value of the expr attribute as an attribute value
template and uses the resulting string as if it were the value of the select attribute. If
you specify the expr attribute, the XSLT processor ignores any contents of xsl:param.
The use of the expr attribute is an extension to the XSLT specification.
Specify template_body. The XSLT processor instantiates this template to obtain the
default value of the parameter.
If you do not specify the select attribute, the expr attribute, or template_body, the
default value of the parameter is an empty string.
For any use of the xsl:param element, there is a region of the stylesheet tree within which
the binding is visible. This region includes the siblings that follow the xsl:param
instruction together with their descendants. Within this region, any binding of the
parameter that was visible on the xsl:param element itself is hidden. Thus, only the
innermost binding of a parameter is visible. The set of parameter bindings in scope for an
expression consists of those bindings that are visible at the point in the stylesheet where
the expression occurs.
The xsl:param instruction can be a top-level element. If it is, it declares a global parameter
that is visible to the entire stylesheet. When the XSLT processor evaluates the select or
expr attribute in a top-level xsl:param instruction, the current node is the root node of the
document.
494
xsl:preserve-space
The xsl:preserve-space instruction is not supported by Stylus Studio. If this instruction
is in a stylesheet, it is ignored.
xsl:processing-instruction
Adds a processing instruction node to the result tree.
Format
<xsl:processing-instruction name = "pi_name">
processing_instruction
</xsl:processing-instruction>
Description
The XSLT processor interprets the name attribute as an attribute value template, and uses
the resulting string as the target of the created processing instruction. The XSLT processor
then instantiates the contents of xsl:processing-instruction to generate the remaining
contents of the processing instruction.
Errors are reported under the following conditions:
If the string that results from evaluating the name attribute is not both an NCName and a
PITarget (see the XSLT Recommendation). Also, the value of the name attribute
cannot be xml.
Example
<xsl:processing-instruction name = "xml-stylesheet">
href="book.css" type="text/css"
</xsl:processing-instruction>
This instruction creates the following processing instruction in the result document:
<?xml-stylesheet href="book.css" type="text/css"?>
495
xsl:sequence
Used within a sequence constructor to construct a sequence of nodes or atomic values.
The sequence is returned as a result of the instruction.
Format
<xsl:sequence
select = expression>
[xsl:fallback]
</xsl:sequence>
Description
Unlike most other instructions, xsl:sequence can return a sequence containing existing
nodes, rather than constructing new nodes. The items comprising the result sequence are
selected using the select attribute. When xsl:sequence is used to add atomic values to a
sequence, the effect is very similar to the xsl:copy-of instruction.
Any optional xsl:fallback instructions are ignored by XSLT 2.0 processors, but they can
be included to define fallback behavior for XSLT 1.0 processors.
Example
This code produces the output, 37.
<xsl:variable name="values" as="xs:integer*">
<xsl:sequence select="(1,2,3,4)"/>
<xsl:sequence select="(8,9,10)"/>
</xsl:variable>
<xsl:value-of select="sum($values)"/>
xsl:sort
Sorts the set of nodes selected by an xsl:apply-templates or xsl:for-each instruction.
Format
<xsl:sort
[select="expression" | expr="expression"]
[optional_attribute]/>
496
Description
The xsl:sort instruction must be the child of an xsl:apply-templates or xsl:for-each
instruction. Each xsl:apply-templates and xsl:for-each instruction can contain more
than one xsl:sort instruction. The first xsl:sort child specifies the primary sort key. The
second xsl:sort child, if any, specifies the secondary sort key, and so on.
When an xsl:apply-templates or xsl:for-each element contains an xsl:sort instruction,
the selected nodes are processed in the order specified by the xsl:sort instructions. When
xsl:sort elements are in an xsl:for-each element, they must appear first before all other
child elements.
You can specify the sort key by using the select attribute, whose value is an expression.
For each node selected by the xsl:apply-templates or xsl:for-each instruction, the XSLT
processor evaluates the expression using the node as the context node. The resulting string
is the sort key for that node. If you do not specify the select attribute, the XSLT processor
uses the string value of the node as the sort key.
When all sort keys for two nodes are equal, nodes remain in document order.
The following optional attributes on xsl:sort determine how the XSLT processor sorts
the list of sort keys. The XSLT processor interprets each of these attribute values as an
attribute value template.
data-type specifies the data type of the strings. The following values are allowed:
text specifies that the sort keys should be sorted lexicographically. All text
sorting is based on Unicode text values.
number specifies that the sort keys should be converted to numbers and then sorted
according to the numeric value. Sort keys that are strings that do not match the
syntax for numbers are sorted as zeros.
The default value is text.
order specifies whether the strings should be sorted in ascending or descending order.
The default is ascending. If the value of the data-type attribute is text, ascending
means that keys are sorted in alphabetical order, and descending means that keys are
sorted in reverse alphabetical order. If the value of data-type is number, ascending
means that keys are sorted in increasing order, and descending means that keys are
ordered in descending order.
The XSLT processor can evaluate xsl:sort order at run time by using an attribute
value template. For example:
<xsl:sort order="{$order)"
497
Example
The following example is from the W3C XSLT Recommendation. Suppose an employee
database has the following form:
<employees>
<employee>
<name>
<first>James</first>
<last>Clark</last>
</name>
...
</employee>
</employees>
xsl:strip-space
The xsl:strip-space instruction is not supported by Stylus Studio. If this instruction is in
a stylesheet, it is ignored.
498
xsl:stylesheet
Specifies the start of a stylesheet.
Format
<xsl:stylesheet
xmlns:xsl="http:///www.w3.org/1999/XSL/Transform" version="1.0" >
stylesheet_body
</xsl:stylesheet>
Description
A stylesheet must specify the xsl:stylesheet element unless it contains only a literal
result element as the root element. The xsl:transform instruction is a synonym for
xsl:stylesheet.
All XSLT elements must appear between the <xsl:stylesheet> and </xsl:stylesheet>
tags. An element that is a child of an xsl:stylesheet element is a top-level element.
xsl:template
Specifies a template rule.
Format
<xsl:template
[match = "pattern"]
[name = "qname"]
[mode = "mode"]
[priority = "priority"]>
template_body
</xsl:template>
Description
The match attribute is required except when you specify the name attribute. The pattern you
specify for the match attribute identifies the source node or set of source nodes to which
the template rule applies.
The optional name attribute specifies a name for the template. You can use the name of a
template to invoke it with the xsl:call-template instruction. The value you specify for
name must be a qualified name. If you specify a name attribute, a match attribute is not
required.
499
The optional mode attribute prevents the template from matching nodes selected by an
xsl:apply-templates instruction that specifies a different mode. The value of mode must
be a qualified name or an asterisk (*). If you specify an asterisk, it means match any node.
If an xsl:apply-templates instruction contains a mode attribute, the xsl:apply-templates
instruction can apply to only those xsl:template instructions that specify a mode attribute
with the same value. If an xsl:apply-templates instruction does not contain a mode
attribute, the xsl:apply-templates instruction can apply to only those xsl:template
instructions that do not specify a mode attribute.
If you specify the match and mode attributes, they have no effect if the template is
instantiated by the xsl:call-template instruction. If you specify the name attribute, you
can still instantiate the template as a result of an xsl:apply-templates instruction.
If two or more templates have the same name, Stylus Studio uses the template that appears
last in the stylesheet.
The template body contains literal results and XSLT instructions. The XSLT processor
instantiates the template body for each node identified by pattern. This means the XSLT
processor copies literal results to the result document and executes the XSLT instructions.
If there is more than one matching template rule, the XSLT processor chooses the
matching template rule with the higher priority. If both have the same priority, the XSLT
processor chooses the one that occurs last in the stylesheet.
For examples and additional information about templates, see Working with Templates
on page 435.
Tip You can create an xsl:template element automatically using the XSLT mapper.
500
xsl:text
Adds a text node to the result tree.
Format
<xsl:text [disable-output-escaping="yes|no"]>
text_node_contents
</xsl:text>
Description
The XSLT processor reports an error if instantiating text_node_contents results in
anything other than characters.
You can also add text nodes to result documents by embedding the text in elements that
you define.
You can specify the disable-output-escaping attribute of the xsl:text instruction. The
allowed values are yes or no. The default is no. If the value is yes, the text node generated
by instantiating the xsl:text element is output without any escaping. For example:
<xsl:text disable-output-escaping="yes"><</xsl:text>
Examples
The following fragment adds two text nodes by embedding text.
<xsl:template match = "/">
<html>
<head><title>Authors and Their Books</title></head>
<body>
<intro>Books in stock are listed here.</intro>
...
</body>
</html>
</xsl:template>
501
xsl:transform
The xsl:transform instruction is a synonym for xsl:stylesheet. See xsl:stylesheet on
page 499.
xsl:value-of
Creates a new text node that contains the string value of an expression.
Format
<xsl:value-of select="expression"
[disable-output-escaping="yes|no"]/>
Description
The XSLT processor evaluates expression and converts the result to a string. If the string
is not empty, a text node is created and added to the result. If the string is empty, the
xsl:value-of instruction has no effect.
You can specify the disable-output-escaping attribute of the xsl:value-of instruction.
The allowed values are yes and no. The default is no. If the value is yes, the text node
generated by instantiating the xsl:value-of element is output without any escaping.
Tip You can create an xsl:value-of element automatically using the XSLT mapper.
Example
<xsl:template match = "author">
<p>
<xsl:value-of select = "first-name"/>
<xsl:text> </xsl:text>
<xsl:value-of select = "last-name"/>
</p>
</xsl:template>
This example creates an HTML paragraph from an author element. The author element
has first-name and last-name children. The resulting paragraph contains the value of the
first first-name child element of the current node, followed by a space, followed by the
value of the first last-name child element of the current node.
502
xsl:variable
Declares a variable and binds a value to that variable.
Format
<xsl:variable name="variable_name"
[select = "expression2"]
[expr = "expression3"]>
template_body
</xsl:variable>
Description
The name attribute is required, and it must be a string. The value of the name attribute is a
qualified name.
The value that you bind to a variable can be an object of any of the types that are returned
by expressions. You can specify the value of the variable in several ways:
Specify the select attribute. The value of the select attribute must be an expression.
The XSLT processor evaluates the expression, and the result is the value of the
variable. If you specify the select attribute, you must not specify any contents for the
xsl:variable instruction. In other words, do not specify template_body.
Specify template_body. The XSLT processor instantiates this template to obtain the
value of the variable. If you specify template_body, you must not specify the select
attribute.
Specify none of the above. In this case, the value of the variable is an empty string.
The difference between the xsl:param and xsl:variable instructions is that
defines a default value while xsl:variable defines a fixed value.
xsl:param
For any use of the xsl:variable element, there is a region of the stylesheet tree within
which the binding is visible. This region includes the siblings that follow the
xsl:variable instruction together with their descendants. Within this region, any binding
of the variable that is visible on the xsl:variable element itself is hidden. Thus, only the
innermost binding of a variable is visible. The set of variable bindings in scope for an
503
expression consists of those bindings that are visible at the point in the stylesheet where
the expression occurs.
The xsl:variable instruction can be a top-level element. If it is, it declares a global
variable that is visible to the entire stylesheet. When the XSLT processor evaluates the
select or expr attribute in a top-level xsl:variable instruction, the current node is the root
node of the document. The xsl:variable instruction is also allowed anywhere in a
template that an XSLT instruction is allowed.
xsl:when
See xsl:choose on page 474.
xsl:with-param
Passes a parameter value to a template.
Format
<xsl:with-param name = "parameter_name"
[select = "expression1]"
</xsl:with-param>
Description
The xsl:with-param instruction passes a parameter value to a template. If the template has
no matching xsl:param declaration, the XSLT processor ignores the parameter. The value
of parameter_name is a qualified name.
The name attribute is required, and it must be a string. The value of the name attribute is a
qualified name.
The value that you pass to a template can be an object of any of the types that are returned
by expressions. You can specify the value of the parameter in several ways:
Specify the select attribute. The value of the select attribute must be an expression.
The XSLT processor evaluates the expression, and the result is the value of the
parameter. If you specify the select attribute, you must not specify any contents for
the xsl:with-param instruction. In other words, do not specify parameter_value.
504
The
Specify parameter_value. If you specify parameter_value, you must not specify the
select or expr attribute.
Specify none of the above. In this case, the value of the parameter is an empty string.
xsl:with-param element
template.
Example
Suppose you specify the following parameter for a template:
<xsl:template name="Appendix">
<xsl:param name = "heading"> 1. </xsl-param>
...
</xsl:template>
505
506
Chapter 6
The XSLT Mapper is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
In addition to writing XSLT manually in the XSLT text editor, Stylus Studio provides a
graphical tool, the XSLT mapper, that allows you quickly compose XSLT without writing
any code. This chapter describes the XSLT mapper, how to use it, and its relationship to
the XSLT displayed on the XSLT Source tab.
For a brief introduction to the mechanics of using the XSLT mapper and some of its
features, see Using the XSLT Mapper Getting Started on page 44.
This chapter covers the following topics:
507
Source document pane, in which you add one or more source documents.
Target structure pane, in which you specify the structure of the result you want the
XSLT to return.
Mapper canvas, on which you can define conditions, functions, and operations for
source document nodes to filter return values that are then mapped to the target node.
508
Source code pane (not shown in Figure 252). The source code pane allows you to
view the source code while using the mapper. This is a great way to see how changes
to the mapper affect the source, without the need to switch to the XSLT Source tab.
Of course, the XSLT Source tab is available if you prefer working with the source
using a full-page view. All views Mapper tab, XSLT Source tab, and the source pane
are synchronized. When displayed, the source pane spans the width of the XSLT
editor.
As you link elements and define XSLT instruction and function blocks in the mapper,
Stylus Studio composes XSLT for you, which is visible (and editable) any time you click
the XSLT editors XSLT Source tab. When you have finished mapping, you can apply the
stylesheet to XML documents that have the same schema as the source document. The
result document also has the same schema as the destination document.
As with the XSLT Source tab, you can preview XSLT results from the Mapper tab by
clicking the Preview Result button ( ). Debugging, however, can be performed from the
XSLT Source tab only.
This section covers the following topics:
Graphical Support for Common XSLT Instructions and Expressions on page 510
Example
Suppose you open the XML mapper and select books.xml as the source document and
catalog.xml as the target document. You then map elements in the books.xml document
or structure to elements in the catalog.xml document or structure. The result is a
stylesheet that you can apply to books.xml and to other files that have a structure similar
to that of books.xml. When you apply this stylesheet, the result is an XML document
whose structure is consistent with that of catalog.xml.
Now suppose you want to apply a stylesheet to catalog.xml and output an XML file that
has a structure similar to books.xml. To do this, you must use the XSLT mapper to create
a second stylesheet. This time, catalog.xml is the source document and books.xml is the
509
destination document. The result of this mapping is a stylesheet that you can apply to
documents that have a structure similar to that of catalog.xml.
XSLT instructions
XPath functions
Logical operators
Java functions
Note The availability of specific XSLT functions is determined by the version of XSLT
specified in the stylesheet. XSLT 2.0 has a much more extensive set of built-in functions
than XSLT 1.0.
Using special symbols, called blocks, you can quickly and easily create complex XSLT
without writing any code, as shown in Figure 253:
Automatically, when you link one node to another. For example, if you link repeating
elements in the source and target documents, Stylus Studio automatically creates an
xsl:for-each instruction block in the mapper.
510
Manually, by selecting the instruction or expression you want to create from the
shortcut menu on the mapper canvas (right click on the mapper canvas to display this
menu).
By reverse-engineering the XSLT that you write on the XSLT Source tab when you
click the Mapper tab, XSLT that can be represented graphically is displayed on the
mapper canvas.
See Working with XSLT Instructions in XSLT Mapper and Processing Source Nodes to
learn more about working with blocks in the XSLT mapper.
stylesheet; mapper metainformation includes the names of source files, node mapping
information, and so on.
If you choose not to save scenario metainformation in the stylesheet, and if the stylesheet
belongs to a project, Stylus Studio saves mapper metainformation in the project. If the
stylesheet does not belong to a project, and you choose not to save metainformation in the
stylesheet, mapping metainformation is not saved.
511
512
You can hide links for nodes that are not currently visible in the Source Document or
Target Document pane by clicking the Hide Links for Nodes that are not Visible button,
as shown in Figure 255:
Links in the Mapper canvas only if both nodes are currently visible in the document
panes
Green arrows (like the ones shown in Figure 256) in the document panes if only one
of two linked nodes is currently visible.
513
Exporting Mappings
You can export a mapping source and target document trees and Mapper canvas contents
as an image file. The default image format is JPEG (.jpg), but you can choose from
other popular image file formats such as .bmp and .tiff.
The exported image reflects the document trees at the time you export the image if you
have collapsed a node in Stylus Studio, for example, that node is also collapsed in the
exported image. However, the exported image includes the entire document tree and
Mapper canvas, not just what is currently visible on the Mapper tab.
By default, all source-target document links are displayed. However, if you have chosen
to hide or show links for only certain nodes, the exported image reflects that choice and
displays only the links for the nodes as you have specified. See Simplifying the Mapper
Canvas Display on page 512 for more information on hiding and showing links.
To export an XSLT mapping:
514
1.
Optionally, hide links for any nodes in the source or target documents that you do not
want to appear in the exported image.
2.
Select XSLT > Export Mapping as Image from the Stylus Studio menu.
Stylus Studio displays the Save As dialog box.
3.
4.
Optionally, change the image type. (The default is JPEG; .bmp and .tiff are also
available.)
5.
Click Save.
You can restrict your search to elements and/or attributes, and you can even search using
regular expressions to define your match pattern.
To display the Find dialog box:
1.
2.
From the Stylus Studio menu bar, select File > New > XSLT: Mapper.
Stylus Studio displays the XSLT editor with the Mapper tab selected.
2.
515
In both the source and the target panes, click the root element and then press the
asterisk key (*) in the numeric key pad to expand the schema tree.
4.
Map nodes in the source documents to nodes in the target document, define XSLT
instructions and functions, and create named and matched templates using the
mappers graphical tools.
Consider working through the source document in document order as you map source
and target elements.
Tip
5.
Check the XSLT Source view from time to time. This allows you to confirm that the
stylesheet is doing what you expect it to do (and it is also a good way to teach yourself
XSLT). Changes you make directly to the source are reflected on the Mapper tab, and
vice versa.
Source Documents
In Stylus Studio, a source document in the XSLT mapper can be one or more of the
following:
An XML document
516
Source Documents
For information on using Zip Archive formatted documents as source documents, see
Working with Zip Archive Format Files as Data Sources on page 862.
window. Stylus Studio displays the source document in the XML editor.
See Source Documents and XML Instances to learn more about how Stylus Studio treats
source documents. See Creating an XSLT Scenario to learn more about XSLT scenarios.
Types of associations
Source documents can have one of three associations, each of which has implications for
the XPath expressions written by Stylus Studio, which uses these documents when it
composes the XSLT stylesheet. A source document can be associated with
517
Itself. That is, the document represented by structure displayed on the Mapper tab and
the XML instance are one in the same. In this situation, Stylus Studio generates the
document() function in the XSLT stylesheet. For example:
document("file://c:\Program Files\Stylus
Studio\examples\simpleMappings\catalog.xml")/books/book
The previous example shows the XSLT that results when an XML document is used
to specify the source structure. This is not possible with XSD or DTD source
documents.
Note
The XML document specified in the XSLT scenario. Only one source document can
be associated with the XSLT scenario. In this situation, Stylus Studio does not
generate the document() function in the XSLT stylesheet. In this situation, the
document() function is not necessary because Stylus Studio uses the XSLT input
document specified in the Scenario Properties dialog box.
By default, Stylus Studio uses the first XML document you add to the XSLT mapper
as the source XML for the XSLT scenario, as shown here:
518
Source Documents
The document specified in the Source XML URL field on the Scenario Properties
dialog box is the document to which the XSLT is applied when you preview the
XSLT. You can select this association for another XML document if you choose, but
only one source document may have this association.
If you specify an XML document as the first source document, Stylus Studio creates
a scenario for you automatically, using that document as the scenarios source XML.
If you specify some other type of document (XSD or DTD), Stylus Studio prompts
you to create a scenario and to specify an XML document as the source when you
preview the XSLT. See Creating an XSLT Scenario.
Note
Some other XML instance. A XSD or DTD document used as a mapper source
document must always be associated with an XML instance. In this situation, Stylus
Studio generates the document() function in the XSLT stylesheet when accessing
nodes of the document structure.
Meaning
The source document is associated with itself. This is the default for
most XML documents (and XML documents only).
The source document is associated with default XML document
specified in the Source XML URL field in the XSLT scenario. This
is the case with the first XML document you add to XSLT mapper, but
you can change this association manually if you choose. See How to
change a source document association.
The source document is associated with a separate XML document
instance. XSD and DTD source documents are always associated with
an XML instance.
519
2.
Right click the source document whose association you want to change.
The source document shortcut menu appears.
3.
Click Associate With, and then select the document you want to associate with the
source document.
2.
Click the Add Source Document button at the top left of the Mapper tab.
The Open dialog box appears.
3.
Select the document you want to use as the source document to map to the target
document.
4.
Click Open.
If you selected an XML document in Step 3, the document appears in the source
document pane of the Mapper tab. Go to Step 5.
If you selected an XSD or DTD document, Stylus Studio displays the Choose Root
Element dialog box.
520
Source Documents
You use the Associate With field to associate the XSD or DTD with an XML instance.
The Associate With field appears only when you add a second document to the XSLT
mapper source and that document is an XSD or DTD. You use it to specify the XML
instance that you want to associate with the XSD or DTD. This field does not appear
if the XSD or DTD is the first source document you add to the XSLT mapper Stylus
Studio uses the XML Source document specified in the Scenario Properties dialog
box as the XML instance in this case.
Note
5.
a.
Select the element from the XSD or DTD document that you want to use as the
root element. The Choose root element drop-down list displays elements defined
in the document you selected in Step 3.
b.
c.
Click OK.
The document appears in the source document pane of the Mapper tab. Go to
Step 5.
2.
Remove any maps from the source document to the target schema. (See Removing
Source-Target Maps if you need help with this step.)
3.
4.
521
Source documents are displayed using the tree view; you can use your standard
keyboards *, +, and - number pad keys to expand and collapse selected documents.
Meaning
Repeating element
Element
Attribute
See Source document icons to learn about the different ways source document icons are
depicted.
522
Target Structures
Target Structures
There are two ways to specify an XSLT target structure:
You can select an existing document from which Stylus Studio infers a structure and,
optionally, modify the structure. Existing nodes in a target structure are displayed in
blue. Nodes that you add are displayed in red.
You can build a structure from scratch, starting with the root element and defining
other elements and attributes as needed. Nodes for target structures you define are
displayed in red.
This section covers the following topics:
2.
Click the Set Target Document button at the top left of the Mapper tab.
The Open dialog box appears.
3.
Select the document you want to use to provide the target structure for defining the
mapping (XML, XSD, or DTD).
4.
Click Open.
The structure of the document you select appears in the target document pane of the
Mapper tab.
523
2.
Right click the area underneath the Set Target Document button.
The target document shortcut menu appears.
3.
524
1.
2.
Select the attribute or element to which you want to add a child element or attribute.
If you have just created a root element, select the root element.
3.
Right click the area underneath the Set Target Document button.
The target document shortcut menu appears.
4.
Add Attribute
Target Structures
Insert Element After (This choice is not applicable to the root element; it creates
Adding a Node
Removing a Node
Adding a Node
See How to create elements and attributes.
Removing a Node
Note Before you can remove a node, you must delete any links to that node. See Removing
Source-Target Maps.
To remove a node from the target structure:
1.
Remove any links to the node you want to remove from the target structure. See
Removing Source-Target Maps if you need help with this step.
2.
525
function blocks, and logical operators. See Working with XSLT Instructions in XSLT
Mapper and Processing Source Nodes.
526
use the right mouse button, Stylus Studio displays a shortcut menu that provides you with
alternatives for modifying the target structure.
Map a source document node to an existing target structure node this menu choice,
Map to This Node, is the same as creating the link using the left mouse button.
Add a source document node as a child element of the target structure node you select
and map the two nodes.
Add a source document node as a sibling of the target structure node you select and
map the two nodes.
Copy the entire source document node its structure and its content to the target
structure and map it.
Using either the left or right mouse button, drag the source document element or
attribute to the appropriate node on the target structure.
If you need help with this step, see Left and Right Mouse Buttons Explained.
Tip
2.
When the pointer is on the appropriate target element, release the mouse button to
complete the link.
527
Stylus Studio draws a link between the source and target nodes you chose is Step 1.
If you linked two repeating elements, Stylus Studio displays a symbol representing
the xsl:for-each instruction. See Working with XSLT Instructions in XSLT Mapper
on page 528.
Select the line that represents the map you want to delete.
Select the portion of the line that is drawn on the XSLT mapper canvas.
Tip
2.
528
xsl:value-of
xsl:for-each
xsl:if
xsl:choose
xsl:apply-templates
xsl:call-template
Note You can create any XSLT instruction in the XSLT source, but only the instructions in
Table 65 are represented graphically in the XSLT mapper. XSLT instructions that are not
supported by the mapper have no graphical representation.
You use these ports to link source and target nodes, to perform processing on source
document nodes, and to provide flow control as the result of a xsl:choose or xsl:if.
Ports are also part of XPath and Java function blocks, logical operator blocks, and text
blocks. (See Processing Source Nodes on page 534 for information on working with these
types of blocks.)
529
Dragging a link from the port to a target document node or to the flow port on another
instruction block.
Double-click the port and typing a value (a string or an XPath expression, for
example) in the Value dialog box.
Tip To see the XSLT that is being generated based on the XSLT instruction you are creating,
right click the instruction and select Go To Source from the shortcut menu.
xsl:value-of
xsl:for-each
Used to define the XPath expression for the select attribute. For
example:
<xsl:for-each select=books/book>
xsl:if
See xsl:if and xsl:choose on page 533 to learn more about when to
use this instruction.
xsl:choose
See xsl:if and xsl:choose on page 533 to learn more about when to
use this instruction.
530
xsl:apply-templates
xsl:call-template
Dragging a link from a source document node or from the output port of another block
(like that of an XPath function or If block, for example).
Double-clicking the port and typing a value (a string or an XPath expression, for
example) in the Value dialog box.
When you mouse over an input port, Stylus Studio displays the value associated with
that port.
Tip
xsl:if
xsl:for-each
You might decide you want a particular xsl:for-each instruction executed only after
performing a certain function, for example.
531
2.
3.
4.
Provide a value for the input port(s). See Specifying Values for Ports on page 530 if
you need help with this step.
5.
6.
To simplify the mappers appearance, Stylus Studio sometimes removes blocks from
the mapper canvas and replaces them with a simple link. For example, imagine
creating an xsl:value-of instruction block and linking source and target document
nodes. Stylus Studio displays the instruction block, but if you leave the Mapper and
later return to it, the block symbol for the xsl:value-of instruction is replaced by a
link with a small circle at its center, link the one shown in Figure 265.
If you mouse over the circle, Stylus Studio displays the XSLT represented by the link
(xsl:value-of select=/books/book/@pubdate/, for example).
This behavior also exists for text blocks created in the mapper that are not also linked
to other blocks in the mapper. See Setting a Text Value on page 538.
532
If you type an XSLT instruction in the XSLT source that is not represented by the
XSLT mapper, no representation of that XSLT instruction is displayed on the Mapper
tab. The code remains as part of the XSLT source, however.
If you start creating an XSLT instruction in the mapper but do not completely define
it (say you specify only the input port for an xsl:for-each instruction, for example),
it is not represented in the XSLT source, and it is removed from the XSLT mapper if
you leave the Mapper tab and then return to it.
Once fully defined, the xsl:if block generates code like the following:
<Review>
<xsl:if test="authors/author= 'Minollo'">
<xsl:value-of select="'Recommended'"/>
</xsl:if>
<xsl:if test="contains(authors/author,'Pedruzzi')">
<xsl:value-of select="'A best buy'"/>
</xsl:if>
</Review>
If you need to express an else condition, use the xsl:choose instruction block. This
instruction block has two output ports by default, one for the xsl:when test= attribute, and
one for the one xsl:otherwise element.
533
If you need to define more than one xsl:when test= attribute, use the xsl:choose shortcut
menu (right click) and select Add When Port.
Note Stylus Studio generates the xsl:otherwise element by default for all xsl:choose
instructions.
534
Input ports
Input ports are on the left side of the function block. The number and definition of input
ports varies from function to function. To specify a value for an input port, you can
Double-click the port and enter the function in the Value dialog box
Flow port
Flow ports on the top of function blocks are generally used only when a function is used
in a direct link between a source and target node.
Output port
The output port is on the right side of the function block. You use the output port to map
the function result directly to a target structure element or attribute, or to an IF, condition,
or another function block.
boolean
ceiling
concat
contains
count
floor
format
535
last
local-name
mod
name
normalize-space
number
position
round
starts-with
string
string-length
substring
substring-after
substring-before
sum
translate
add
div
multiply
subtract
You can easily express these functions by typing them in the Value dialog box displayed
when you double-click an input port.
536
2.
In the shortcut menu that appears, click XPath Functions and slide to the submenu.
3.
Click the function you want to use. Stylus Studio displays a function block for the
function you selected.
Logical Operators
The Stylus Studio XSLT mapper allows you to graphically define the following types of
conditions:
Equal (=)
and (&)
or (||)
All condition blocks have two input ports and a single output port, as shown in this
example of a greater than block.
You can map the return port to a target structure element or attribute, or to the input port
on an XSLT instruction, XPath function, or another condition block.
537
Example
Here is the XSLT code Stylus Studio generates for the Title element when a text value is
specified for it:
<Book>
<Title>Confederacy of Dunces</Title>
</Book>
Stylus Studio displays a red letter T for nodes for which you define a text value:
2.
538
You can also display the Value dialog box by selecting Properties from the text block
shortcut menu (right click).
Tip
3.
4.
Drag a link from the text blocks output port to the target node to which you want to
assign the text value.
Note Unless the text block is linked to another block (such as a logical operator or an XPath
function), Stylus Studio removes it from the mapper canvas if you leave and then return
to the Mapper tab. In this case, a red T is displayed next to the target nodes name.
Right-click the node for which you want to set the text value.
The shortcut menu appears.
2.
Type the string you want to use as the text value and click OK.
539
2.
Create the class file for your function. See About Adding Java Class Files on
page 540 for more help with this step.
3.
4.
5.
In the pop-up menu that appears, select Java Functions > Register Java Extension
Class.
6.
In the Java Class Browser dialog box that appears, navigate to and select the Java
class that provides your function.
7.
Now when you select Java Functions from the mapper short-cut menu, the list of
functions includes the function you registered.
540
You can change the template view at any time, by selecting the template from the dropdown list, as shown in Figure 275.
template.
541
2.
Select Create Template > Named Template or > Matched Template from the shortcut
menu.
Stylus Studio displays the Named Template (or Matched Template) dialog box. (The
Named Template dialog box is shown in Figure 276.)
You can use a mode to define the conditions under which a template will be applied
by a stylesheet.
Tip
4.
5.
542
b.
c.
d.
Global Parameters
XSLT Processors
543
the scenario. You can specify the XML source document setting on the General tab of the
Scenario Properties dialog box.
See Source Documents to learn more about the process of selecting and working with
source documents in XSLT mapper.
Global Parameters
The Parameter Values tab of the Scenario Properties dialog box displays any global
parameters you have defined in the XSLT source and allows you to
544
If you want to specify an alternate parameter value for this scenario, click the Parameter
value to be used when processing entry field. If the alternate value you enter is an XPath
expression, click the associated check box.
By default, values entered in the Paramter value to be used when processing field are
interpreted as strings. However, you can indicate that you want the value to be interpreted
as an XPath expression by selecting the check box in the Parameter value is an XPath
expression (not a string) field. This allows you to enter expressions such as the following:
document("books.xml")/books/book[1]
Tip All global parameters you define for a stylesheet are displayed on the Params/Other tab
of the XSLT Editor. Parameters displayed on the Params/Other tab are read-only.
545
XSLT Processors
By default, Stylus Studio uses the Saxon processor to process XSLT documents. You can
change the processor on the Processor tab of the Scenario Properties dialog box.
You can choose from a number of third-party processors that are bundled with Stylus
Studio, or you can specify your own custom processor.
Note Not all third-party processors, including any custom processors you might specify,
The Stylus Studio built-in XML validator. If you use the Stylus Studio built-in
validator, you can optionally specify one or more XML Schemas against which you
want the result document to be validated.
Any of the customizable validation engines supported by Stylus Studio, such as the
.NET XML Parser and XSV.
All validation is done before any post-processing that you might have specified.
See Validating Result Documents on page 445.
2.
In the Scenario name: field, type the name of the new scenario.
3.
In the Source XML URL (optional): field, type the name of the XML file to which you
want to apply the XSLT, or click Browse
to navigate to an XML file and select it.
If the first document you added to the XSLT mapper is an XML document, Stylus
Studio uses that document as the XML source for the scenario and displays it in this
field.
Note
4.
In the Output URL field, optionally type or select the name of the result document you
want the XSLT document to generate. If you specify the name of a file that does not
exist, Stylus Studio creates it when you preview the XSLT.
547
If you want Stylus Studio to Store paths relative to XSLT document path, ensure that
this option is checked.
6.
If you check Preview result in an external application, Stylus Studio displays the result
Internet Explorer. In addition, Stylus Studio always displays XSLT results in the
Preview window
7.
Optionally, configure settings for global parameters, the XSLT processor you want to
use, whether or not you want to run a profiling report, and whether or not you want to
perform any post-processing on the XSLT result. See Overview of Scenario Features
on page 543 for more information.
8.
To define another scenario, click Add and enter the information for that scenario. You
can also copy scenarios. See How to Clone a Scenario on page 549.
9.
Click OK.
If you start to create a scenario and then change your mind, click Delete and then OK.
2.
548
Select a scenario from the scenario drop-down list at the top of the editor window.
Alternative:
a.
b.
On the General tab, select the scenario you want to run from the Existing
Scenarios list.
c.
Click OK.
).
2.
3.
In the Scenario Properties dialog box, in the Existing preview scenarios field, click
the name of the scenario you want to clone.
4.
Click Clone.
5.
In the Scenario name field, type the name of the new scenario.
6.
Change any other scenario properties you want to change. See How to Create a
Scenario on page 547.
7.
Click OK.
If you change your mind and do not want to create the clone, click Delete and then OK.
549
550
Chapter 7
Debugging Stylesheets
Stylus Studio provides several tools that allow you to follow XSLT processing and detect
errors in your stylesheets. To use these tools, you must use the processors displayed in the
Debug and back-mapping enabled section of the Processors page on the Scenario
Properties dialog box. These processors include Stylus Studios XSLT processor,
MSXML .Net, and Saxon 6 and 8. If you use the MSXML XSLT processor or some other
XSLT processor, you cannot use the Stylus Studio debugging and backmapping tools.
You can also use the Stylus Studio debugger to analyze Java files, or applications that
include both stylesheets and Java files. In addition, you can use Stylus Studio to debug
JavaScript and VBScript extension functions. See the Microsoft documentation for
information about these extension functions.
This section discusses the following topics:
551
Debugging Stylesheets
Open a stylesheet.
2.
Set up a scenario or select the scenario you want to use. See Applying Stylesheets
on page 419.
3.
4.
Apply the stylesheet by pressing F5, not clicking Preview Result. If you click Preview
Result, Stylus Studio applies the stylesheet without invoking the debugger.
5.
Examine the information in the debugging tools and in the Preview window.
6.
7.
Iteratively step through the stylesheet or program and examine the information in the
debugging tools.
You can include msxml:script elements in XML documents in Stylus Studio. The msxml
prefix must indicate the Microsoft urn:schemas-microsoft-com:xslt namespace.
The following sections provide the details for performing each of these steps.
Using Breakpoints
The Stylus Studio debugger allows you to interrupt XSLT or Java processing to gather
information about variables and processor execution at particular points.
Inserting Breakpoints
To insert a breakpoint:
552
1.
In the XSLT stylesheet or Java file in which you want to set a breakpoint, place your
cursor where you want the breakpoint to be.
2.
Removing Breakpoints
To remove a breakpoint:
1.
2.
Start Debugging
When your stylesheet or Java file has one or more breakpoints set, start processing by
or pressing F5. When Stylus Studio reaches the first
clicking Start Debugging
breakpoint, it suspends processing and activates the debugging tools. After you examine
the information associated with that breakpoint (see Viewing Processing Information
on page 553) you can choose to
553
Debugging Stylesheets
554
A path that shows which node in the stylesheet was being processed when processing
was suspended
Local variables that are defined at that point in the processing and their values.
A special variable named this. The this variable represents the object being
processed. It allows you to drill down and obtain additional information.
You can expand and collapse complex structures as needed.
555
Debugging Stylesheets
The Call Stack window and the Backmap Stack window provide the same kind of
information. However, the Backmap Stack window never shows Java entries, and the
contents of the Backmap Stack window can be different from the Call Stack window
according to where you click in the output to enable backmapping.
Open a stylesheet.
2.
3.
In the Preview window, in either the text view or the browser view, click on the output
for which you want to display the XSLT calls.
Stylus Studio displays the Backmap Stack window, which lists one or more XSLT
instructions. Also, Stylus Studio flags the line in the stylesheet that contains the first
instruction in the list. To find the location of another listed instruction, click that
instruction in the Backmap Stack window.
The Call Stack window and the Backmap Stack window provide the same kind of
information. However, the Backmap Stack window never shows Java entries, and the
contents of the Backmap Stack window can be different from the Call Stack window
according to where you click in the output to enable backmapping.
Using Bookmarks
When you are editing or debugging a long file, you might want to repeatedly check certain
lines in the file. To quickly focus on a particular line, insert a bookmark for that line. You
can insert any number of bookmarks. You can insert bookmarks in any document that you
can open in Stylus Studio.
To insert a bookmark:
1.
556
To remove a bookmark:
1.
Click in the line that has the bookmark you want to remove.
2.
Click Toggle Bookmark in the Stylus Studio tool bar. Stylus Studio removes the
turquoise box.
or Previous
557
Debugging Stylesheets
The report format is controlled by the default XSLT stylesheet, profile.xsl, in the \Stylus
You can customize this stylesheet as required. You can save XSLT
Profiler reports as HTML.
Studio\bin directory.
Note XSLT and XQuery Profiler reports use the same XSLT stylesheet.
558
In addition to generating the standard XSLT Profiler report, you can save the raw data
generated by the Profiler and use this data to create your own reports. See Enabling the
Profiler on page 559 for more information about this procedure.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XSLT Profiling video.
A complete list of all the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
About Metrics
The XSLT Profiler can record three different levels of performance metrics:
the XSLT itself. Consider using the Profiler with the first two performance metric
options. You can also use the Limit Trace To fields to further restrict the Profilers scope.
If you find you need still more detail (while troubleshooting a performance bottleneck,
for example), use the step-by-step setting.
Open the Scenario Properties dialog box for the XSLT stylesheet. (Click Browse
at the top of the XSLT editor window.)
559
Debugging Stylesheets
2.
Select the settings for the performance metrics you want the Profiler to capture.
4.
Note
5.
Click OK.
The next time you preview the XSLT results, the performance metrics you selected
are available to you in the XSLT Profiler report (and as raw data if you selected that
setting and specified a file).
560
1.
Ensure that the Profiler is enabled. (See Enabling the Profiler on page 559 if you
need help with this step.)
2.
3.
).
561
Debugging Stylesheets
To run the auto-detect feature:
1.
Select Tools > Options from the Stylus Studio menu bar.
2.
3.
Also, in the Parameters field of the Java Virtual Machine page, there should be something
like the following:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,
server=y,suspend=n,address=8000 -Djava.compiler=NONE
To confirm that your set up is correct, select Help > About Stylus Studio from the Stylus
Studio menu bar. The Java Virtual Machine field in the About Stylus Studio dialog box
should indicate that the JVM is running in debug mode.
Source Path is the path that Stylus Studio uses to locate the source files during
debugging.
Prompt user for source file path confirmation indicates that if Stylus Studio cannot
find the source files you are debugging, it prompts you to specify the source file path.
If you do not set this option, and Stylus Studio cannot find a source file, the behavior
varies according to what the debugger is trying to do. For example, if the debugger is
stepping into an instruction that calls a function that is defined in a Java file that Stylus
Studio cannot find, the debugger steps over the instruction.
562
Never step into classes starting with one of the following strings of characters:
contains a list of classes, one on each line, that you do not want to step into. For
example, these might be classes that are part of the core language, or classes that you
do not have source files for. If you specify java.lang, the debugger skips all classes
whose names start with java.lang, for example, java.lang.String and
java.lang.Object.
JVM communication time out indicates the amount of time that Stylus Studio waits
for a response from the JVM. If Stylus Studio does not receive a response in the
specified amount of time, it stops trying to communicate with the JVM. The default
is 5 seconds.
Show JDWP Events in the Output Window indicates whether you want Stylus Studio
to log all communication events in the Stylus Studio Output Window during a
debugging session.
Stylus Studio also allows you to set options that specify the Java virtual machine (JVM)
you use. You can specify the run-time library, the home directory, and parameters for
starting the JVM. Select Tools > Options from the Stylus Studio menu bar.
See Specifying Stylus Studio Options on page 120 for instructions for setting these
options.
563
Debugging Stylesheets
CLASSPATH environment
Select Tools > Options from the Stylus Studio menu bar.
2.
In the Options dialog box that appears, click General > Java Virtual Machine.
564
From the Stylus Studio menu bar, select Tools > Options.
2.
In the Options dialog box that appears, click Java Virtual Machine.
3.
4.
5.
Double-click IntDate.xsl.
Stylus Studio opens the IntDate.xsl stylesheet in the XSLT editor. The tree for the
XML source document, IntDate.xml, also appears.
6.
In the XSLT editor, examine the template that matches the date element.
As you can see, the select attribute in the xsl:value-of instruction invokes the
IntDate Java extension function.
2.
In the body of the template, click just before the xsl:value-of instruction.
3.
4.
.
.
565
Debugging Stylesheets
The XSLT processor suspends processing at the breakpoint, displays a yellow triangle
to indicate where processing has been suspended, and displays a message in the
Preview window.
566
1.
2.
3.
4.
5.
Chapter 8
This section provides information about how to use Stylus Studio to define an XML
Schema. Although some information about XML Schema tags is provided, familiarity
with the W3C XML Schema Recommendation is assumed.
Many of the examples in this chapter are based on the purchaseOrder.xsd document,
which is installed with other sample files in the examples\simpleMappings directory of
your Stylus Studio installation directory. Consider having this file open as you read
through the examples in this chapter.
This section covers the following topics:
Getting Started with XML Schema in the Tree View on page 592
567
Reference Information
The World Wide Web Consortium (W3C) provides information about XML Schema,
including the following:
You can also create XML Schema from EDI message types and transactions, like those in
EDIFACT, X12, and IATA dialects. See Creating XML Schema from EDI on page 577.
Stylus Studio displays a new XML document in the XML Schema Editor Diagram tab;
the text pane displays the following contents:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</xsd:schema>
When you create an XML Schema in Stylus Studio, the default namespace is specified as
http://www.w3.org/2001/XMLSchema. If you choose to you specify the XML Schema
namespace, be sure to specify one of the following:
http://www.w3.org/2001/XMLSchema
http://www.w3.org/2001/XMLSchema-instance
From the Stylus Studio menu bar, select File > Document Wizards.
The Document Wizards dialog box appears.
569
In the XML Editor tab, click DTD to XML Schema, and click OK.
The Convert DTD to XML Schema dialog box appears.
In the DTD URL field, type or select the absolute path for the DTD from which you
want to create an XML Schema.
The DTD must be encoded in UTF-8.
Note
4.
If you want to specify a target namespace for the resulting XML Schema, select the
Use a Target Namespace check box and type a target namespace URL.
5.
Click OK.
Stylus Studio displays the new XML Schema in the XML Schema Editor.
570
FIeld
Description
[input] xmlns=<uri>
Description
[input] xmlns:<prefix=uri>
[input] colonreplacement=<chars>
[input] element-define=<namepattern>
571
572
FIeld
Description
[input] attlist-define=<namepattern>
[input] any-name=<name>
[input] strict-any
[input] annotationprefix=<prefix>
[output] encoding=<name>
[output] indent=<n>
[output] disable-abstractelements
Description
[output] any-processcontents=strict|lax|skip
[output] any-attribute-processcontents=strict|lax|skip
From the Stylus Studio menu bar, select File > Document Wizards.
The Document Wizards dialog box appears.
2.
In the XML Editor tab, click DTD to XML Schema (Trang) and click OK.
The DTD to XML Schema (Trang) dialog box appears.
573
Enter the absolute path of the DTD from which you want to create an XML Schema.
The DTD must be encoded in UTF-8. You can type the file path, or use the browse
button (which appears when you place the cursor in the Input file (required) field. This
is the only required field.
4.
5.
Click OK.
Stylus Studio displays the new XML Schema in the XML Schema Editor.
The XML to XML Schema document wizard allows you to create XML Schema from
any XML document. The XML document you use to create the XML Schema is not
modified with attribute information about the new XML Schema when you use this
method.
The Create Schema from XML Content feature in the XML Editor. This method
allows you to create an XML Schema (or DTD) based on the current XML document
in the XML Editor. The XML document is always modified with namespace and
schema location attributes when you use this method. If you choose to create DTD,
you have the option of creating internal or external DTD.
Both methods allow you to specify the URI for the generated files (if an XML document
has multiple namespaces defined for it, Stylus Studio creates a separate XML Schema
associated with each namespace).
574
Specify the XML document you want to use to create an XML Schema in the XML
Document field.
4.
Specify the URI for the generated file(s) in the Generated XSD field.
5.
Open the XML document from which you wish to create an XML Schema.
575
Select XML > Create Schema from XML Content from the Stylus Studio menu.
The Create Schema or DTD dialog box appears.
4.
Type a name for the XML Schema you want to create, or use the browse button (
to search for an existing file.
5.
576
1.
2.
Wizard Options
Though specifics vary across EDI dialects (IATA and EANCOM refer to versions, while
X12 refers to Release, for example), the options for most EDI document wizards are
similar, if not the same. Document wizard options are summarized in the following table.
Once specifying the dialect and version, you use the fields of the XML Structure group
box to specify the structure of the XML; you use the fields of the XML Schema Options
group box to specify the settings that are used to generate the XML Schema for the
selected EDI message.
Table 68. EDI Document Wizard Options
Option Name
Description
Dialect
The EDI dialect from which you want to create an XML Schema.
Version
The version of the EDI dialect from which you want to create an
XML Schema.
Mode
Message
The specific message type from which you want to create an XML
Schema.
577
578
Option Name
Description
Whether or not you want to use the long element name as part of the
XML tag UNB01-SyntaxIdentifier versus UNB01, for example
Wrap GROUP
element around message
groups
Places code list data values in an value= string in the element tag.
For example, <BGN01 value="00"><!--353: Transaction Set
Purpose Code--></BGN01>. By default, the data value is output to
XML as text (<BGN01><!--353: Transaction Set Purpose Code->00</BGN01>).
Write annotations
describing each element
Enumerations for
elements that have
codelists
SEF File
The URI of the Standard Exchange Format (SEF) file, if any, you
want to use when generating XML Schema. The SEF file can
augment information that Stylus Studio uses to generate XML
Schema customized EDI definitions are stored in the SEF file, for
example. If the same setting is specified by both the document
wizard and the SEF file, the SEF file value is used.
Select File > Document Wizards from the Stylus Studio menu.
The Document Wizards dialog box appears.
2.
579
580
4.
5.
Select the message or transaction set on which you wish to base the XML Schema
you are creating.
6.
Change the XML Schema creation options as required. See Wizard Options on
page 577 if you need help with this step.
7.
Click OK.
Stylus Studio converts the EDI you selected in Step 5 to XML Schema and opens a
new, untitled document in the XML Schema Editor.
581
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XML Schema Diagram Editor
video.
You can see other Stylus Studio video demonstrations here:
http://www.stylusstudio.com/xml_videos.html.
Each tab displays the schema from a unique perspective, as summarized here:
Diagram Displays the XML Schema using graphical elements for the nodes
(elements, attributes, simpleTypes, complexTypes, and so on) defined in the XML
Schema in a diagram pane. Container elements can be expanded to show child
582
elements, and values such as element and attribute names and types can be edited in
place by double-clicking the node you want to modify.
In addition to the diagram pane, the Diagram tab includes a text pane. The text pane
displays the raw XML text used to define the XML Schema, and lets you see how the
changes you make in the diagram affect the XML Schema text. You can make
changes in either pane to a node in the diagram, or directly to the text Stylus Studio
keeps both views synchronized.
The Diagram tab has a full complement of editing tools, including checkers for wellformedness and validation, as well as a query functionality that lets you evaluate your
query using either XPath 1.0 or XPath 2.0. XML Schema query is also supported in
the Tree tab. See <hyperlink>Printing on page 587 to learn how to print information
in the Diagram tab.
For more information on the Diagram tab, including a description of the graphical
symbols used to represent XML Schema elements, see Introduction to the XML
Schema Editor Diagram Tab on page 67.
Tree Displays a DOM tree representation of the XML Schema. You can edit the
XML Schema graphically, in the tree itself, or by modifying the properties of the
nodes you select.
583
about the XML Schema, including sections for schema document properties, global
declarations, and global definitions.
584
2.
3.
button.
585
If you want, you can create a new XML document based on this instance by clicking the
Open as New Document button.
Note If the XML Schema contains an element defined using a built-in type, the instance of that
element in the XML document is created using the minimum value of the range specified
for that type. For example, if the XML Schema contains a <part> element defined as
type=xs:integer, the <part> element in the resulting XML document appears as
<part>-9223372036854775808</part>.
To view sample XML:
586
1.
In the Diagram tab, select the node for which you want to see sample XML.
2.
Select Diagram > View XML Sample from the Stylus Studio menu.
Alternative: Select View XML Sample from the nodes shortcut menu (right-click to
display).
The View Sample XML dialog box appears. (See Figure 291.)
3.
If you want to open this instance as a new XML document in Stylus Studio, click the
Open as a New Document button. Otherwise, click Close Preview.
Printing
You can print XML Schema from the Diagram tab, and you can print XML Schema
documentation from the Documentation tab.
2.
Click Print
.
Alternative: Select File > Print from the Stylus Studio menu.
587
Select Diagram > Export Image from the menu, or select Export Image from the
shortcut menu on the diagram pane (right-click).
Stylus Studio displays the Save As dialog box.
588
3.
Select the file format (.jpg or .emf) from the Files of type drop-down list.
4.
Specify a name and location for the file and click the Save button. The default name
is the name of the XML Schema document; the default location is the folder in which
the XML Schema document has been saved.
Node Properties
The Properties window is available when you are using the Diagram or Tree tab of the
XML Schema Editor. When the Properties window is open, it displays the properties of
the node you click. If you have selected a restricted node from a redefined XML Schema,
Stylus Studio displays a separate section in the lower half of the Properties window for
you to specify the facets, as shown in Figure 292.
If the Properties window is not visible, select View > Properties from the Stylus Studio
menu.
Tip The Properties window is a dockable window you can drag it out of Stylus Studio and
Global elements
589
In addition to the current XML Schema, Stylus Studio searches any included or imported
XML Schemas for references.
Search Results
Search results are displayed in the Output window, as shown in Figure 293. Information
in the result includes
The name of the node whose references you are looking for
Searched files (that is, the current XML Schema and any included or imported XML
Schemas)
Pressing F4:
Scrolls the text pane to the referencing node (note the blue marker in the text pane
margin)
Select the XML Schema node for which you want to find referencing nodes.
2.
591
Defining a complexType in a Sample XML Schema in the Tree View on page 593
Defining Elements of the Sample complexType in the Tree View on page 598
For instructions for using the Diagram view to define the same XML Schema, see
Defining an XML Schema Using the Diagram Tab Getting Started on page 66.
There must be at least one author element and there can be more. Each author
element contains one first-name element and one last-name element.
592
ISBNnumber
PUBnumber
LOCnumber
Defining the Name of the Sample complexType in the Tree View on page 593
Adding Optional Elements to a Sample complexType in the Tree View on page 596
Choosing the Element to Include in the Sample complexType in the Tree View on
page 597
From the Stylus Studio menu bar, select File > New > XML Schema.
Stylus Studio displays the XML Schema Editor.
2.
At the bottom of the XML Schema Editor, click the Tree tab.
Stylus Studio displays the Tree view of the schema, and the Properties window,
which lists the properties for the selected node in the tree.
3.
4.
.
.
593
Type PublicationType as the name for this new complexType and press Enter.
6.
Click Save
7.
In the Save dialog box that appears, in the URL field, type bookstoreTree.xsd, and
click Save.
2.
3.
Type genre as the name of the new attribute and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
4.
Double-click xsd:string.
594
1.
2.
3.
4.
Type title as the name of the new element and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
6.
Double-click xsd:string.
595
2.
3.
Type subtitle as the name of the new element and press Enter.
Stylus Studio displays a drop-down list of built-in simpleTypes.
4.
Double-click xsd:string.
5.
6.
7.
8.
596
1.
2.
3.
Type authorType as the name for this new complexType and press Enter.
Stylus Studio User Guide
5.
6.
7.
In the field that Stylus Studio displays, type first-name as the name of the new
element and press Enter.
8.
9.
10.
Repeat Step 6 through Step 8, but type last-name as the name of the new element.
Now you can add the author element to the PublicationType complexType:
1.
In the Tree view, click the sequence node under the PublicationType node.
2.
3.
In the field that Stylus Studio displays, type author as the name of the new element
and press Enter.
4.
5.
6.
7.
8.
In the Tree view, under the PublicationType node, click the sequence node.
2.
3.
597
5.
In the field that Stylus Studio displays, type ISBNnumber as the name of the new
element and press Enter.
6.
In the drop-down list that appears, scroll until you can double-click xsd:integer, or
type xsd:integer and press Enter.
7.
8.
Repeat Step 4 through Step 7 two more times. Once for the PUBnumber element and
once for the LOCnumber element.
9.
Click Save
.
Stylus Studio displays a message that indicates that the schema is not valid. Click OK
in the error box. In the Output Window, you can see the following message:
Validating bookstoreTree.xsd...
file://c:\yourDirectory\bookstoreTree.xsd:6,45:
Invalid child 'sequence' in the complexType
The XML document bookstoreTree.xsd is NOT valid (1 errors)
The problem is that there is a sequence element after an attribute element. The
must come first.
sequence element
10.
11.
12.
and Save
The definition of the PublicationType complexType is now complete and the schema is
now valid.
598
1.
2.
3.
In the field that Stylus Studio displays, type book as the name of the new element and
press Enter.
4.
Repeat Step 1 through Step 4 two more times. Once for the magazine element and
once for the newsletter element.
6.
Click Save
This is the end of the section that provides instructions for getting started with defining
XML Schemas in the Tree view. The topics that follow this topic provide complete
information for defining the elements that can be in an XML Schema and for working in
the Diagram, Tree, and Text views.
Defining List and Union simpleTypes in the Tree View on page 608
Atomic is the term for most of the simpleTypes built in to XML Schema, such as
integer, string, and decimal. They are called atomic because in the context of
XML Schema, no part of an element or attribute of an atomic type has meaning on its
own. It is only the whole instance that has meaning.
Descriptions of the XML Schema built-in types are in the W3C XML Schema Part 2:
Datatypes at http://www.w3.org/TR/xmlschema-2/.
List simpleTypes are sequences of atomic types. All elements of a particular list
simpleType are instances of the same atomic type.
Union simpleTypes are sequences of atomic and list types. However, the elements of
a particular union simpleType can be instances of more than one atomic or list type.
Stylus Studio User Guide
599
Anonymous simpleTypes are simpleType definitions that are not explicitly named. An
anonymous simpleType can be an atomic, list, or union simpleType. You define an
anonymous simpleType in the element or attribute definition that uses it.
Anonymous simpleTypes are useful when you want to define a type that is used in
only one element or attribute. By specifying an anonymous simpleType, you save the
overhead of explicitly defining the type and specifying a reference to it.
This specifies that SKU is a simpleType. It is restricted to the values of the base type, which
is xsd:string. This means that for a node that is of type SKU, the possible values are a
subset of the values allowed for the xsd:string type.
The xsd:pattern element specifies that the pattern facet is being applied to the set of
values allowed by the xsd:string type. The value of the xsd:pattern element is an XML
Schema regular expression that specifies the allowable values for nodes of type SKU. In this
example, the regular expression specifies that the value must be three digits, followed by
a hyphen, followed by two uppercase ASCII letters <xsd:pattern value="\d{3}-[AZ]{2}"/>. For information about XML Schema expressions, see the W3C XML Schema
Part 0: Primer at http://www.w3.org/TR/xmlschema-0/.
Elsewhere in the purchase order schema, an attribute definition specifies that SKU is the
type of its value:
<xsd:attribute name="partNum" type="SKU" use="required"/>
An XML document that uses a schema that contains this simpleType definition can
specify the partNum attribute. The parser ensures that the value of the partNum attribute is
in the range specified by the xsd:pattern element. The SKU type itself is not mentioned in
the instance document.
600
Following is another example of a simpleType definition from the W3C XML Schema Part
0: Primer. This simpleType, myInteger, is based on the xsd:integer type. It specifies two
facets (minInclusive and maxInclusive), which specify the lower and upper inclusive
bounds of the range of valid values.
<xsd:simpleType name="myInteger">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="10000"/>
<xsd:maxInclusive value="99999"/>
</xsd:restriction>
</xsd:simpleType>
2.
3.
Change the default name to the name of the new simpleType and press Enter.
601
2.
The Type Derivation dialog box displays the W3C XML Schema, as well as any
referenced XML Schemas.
3.
Expand the schema (click the plus sign) to display the base types associated with that
XML Schema.
4.
Select the type on which you wish to base the simpleType you are defining and click
OK.
The simpleType is updated with an element that identifies the restricted type:
In the lower half of the Properties window, Stylus Studio displays a section that
allows you to specify facets values that define the constraint on the range of values
allowed by the base type.
602
Stylus Studio displays only those facets that are allowed for the base type you
selected. For a description of each facet, see About Facet Types for simpleTypes on
page 607.
6.
7.
8.
2.
603
4.
In the Properties window, select the type on which you want to base the simpleType
you are defining from the Base Type field.
At the bottom of the Properties window, Stylus Studio displays a section that allows
you to specify facets values that define the constraint on the range of values
provided by the base type.
5.
Stylus Studio displays only those facets that are allowed for the base type you
selected. For a description of each facet, see About Facet Types for simpleTypes on
page 607.
6.
7.
8.
604
Select the type (list or union) from the shortcut menu (right-click the new simpleType
and select Add > List or Add > Union).
3.
Specify the nodes that comprise the simpleTypes list or union. These types are
restricted to annotations and other simpleTypes.
How you perform this last step depends on whether you are adding new or existing
annotation or simpleType nodes to the list or union.
To add a new, undefined annotation or simpleType to the list or union, right click the
list or union and select Add > Annotation or Add > SimpleType from the shortcut
menu.
To add an existing annotation or simpleType to the list or union, drag the annotation
or simpleType to the list or union, and drop it there, as shown in Figure 299, which
shows SimpleType-6 being added to the union SimpleType-3.
Notice that the pointer changes shape when you place it over an appropriate target
node.
Click the node you want to define a simpleType for. This can be one of the following
types of nodes:
schema
element
attribute
list
union
605
To define a simpleType as the sibling of another node, click the node and hold down
the Shift key when you click the button in Step 2. You cannot, of course, define a
simpleType as a sibling of the Schema node.
606
2.
3.
4.
5.
Double-click the simpleType that you want to base your new simpleType on.
6.
7.
8.
9.
10.
To add another facet, click the restriction node for your simpleType, and repeat Step 6
through Step 9.
Value
enumeration
fractionDigits
length
maxExclusive
The exclusive upper bound of the range of values allowed for this
simpleType. The value of the simpleType must be less than the
value of maxExclusive.
maxInclusive
The inclusive upper bound of the range of values allowed for this
simpleType. The value of the simpleType must be less than or
equal to the value of maxInclusive.
maxLength
607
Value
minExclusive
The exclusive lower bound of the range of values allowed for this
simpleType. The value of the simpleType must be more than the
value of minExclusive.
minInclusive
The inclusive lower bound of the range of values allowed for this
simpleType. The value of the simpleType must be equal to or
more than the value of minInclusive.
minLength
pattern
totalDigits
whiteSpace
preserve indicates
608
Click the node you want to define the list or union type for.
2.
3.
4.
5.
6.
Define the atomic simpleType of the elements or attributes that are instances of the
list or union type. See Defining simpleTypes in XML Schemas on page 599.
7.
If you are defining a list type you are done. If you are defining a union type, click
the union node and define another atomic simpleType that can be in the union.
Perform this step for each type in the union.
your complexTypes name in the menu that lists the available types for your new element.
You can select the name of the complexType from the menu.
You can also define a complexType in the definition of an element. See Defining
Elements That Contain Subelements in XML Schemas on page 623.
Stylus Studio takes care of most of the details for you. But as you define a complexType,
it is helpful to keep in mind that a complexType node can have only one child node that is
a model group modifier. However, this modifier node can have any number of child nodes
that are modifiers. In this way, you can specify any number of modifiers in a
Stylus Studio User Guide
609
complexType. Each modifier controls the occurrence of its child nodes. You can specify
the same modifier more than once. For example, you might want to specify the sequence
modifier, with some child nodes, then the choice modifier with some child nodes, and
then the sequence modifier again with other child nodes.
This section discusses the following topics:
2.
610
1.
2.
3.
Fully describe the complexType and its nodes by editing values in the Properties
window.
You can use this procedure to add the following nodes to a complexType:
all
annotation
anyAttribute
attribute
attributeGroup
choice
group
sequence
Next steps vary according to the constraints on the elements in the complexType. The
following instructions show how to achieve some typical constraints.
Choosing an Element
Suppose you want to define a complexType that contains exactly one element, and that
element can be one of several different elements. In XML Schema, you do this by defining
xsd:choice.
To define xsd:choice in the Diagram tab:
1.
2.
3.
Right-click the choice icon and select Add > Element, or use the Add button
A element is added to the choice icon.
Make sure the new element is selected. In the Properties window, click the Type field.
5.
6.
Repeat Step 3 through Step 5 for each element that might be in the complexType.
611
2.
3.
Right-click the choice icon and select Add > Element, or use the Add button
A element is added to the all icon.
4.
Make sure the new element is selected. In the Properties window, click the Type field.
5.
6.
If the element is required, go to Step 7. If the element is optional, click the Min Occur.
field in the Properties window, and type a zero (0).
7.
If there must always be exactly one of this element, go to Step 8. If there can be more
than one of this element, click the Max Occur. field in the Properties window, and
enter the maximum number allowed or click unbounded in the drop-down list.
8.
Repeat Step 3 through Step 7 for each element that can be in the complexType.
612
1.
2.
3.
Right-click the sequence icon and select Add > Element, or use the Add button
A element is added to the sequence icon.
4.
Make sure the new element is selected. In the Properties window, click the Type field.
5.
6.
If the element is required, go to Step 7. If the element is optional, click the Min Occur.
field in the Properties window, and type a zero (0).
7.
If there must always be exactly one of this element, go to Step 8. If there can be more
than one of this element, click the Max Occur. field in the Properties window, and
enter the maximum number allowed or click unbounded in the drop-down list.
8.
Repeat Step 3 through Step 7 for each element that can be in the complexType.
Reordering Nodes
If you make a mistake in the order in which you specify nodes in your XML Schema
(when specifying elements in a sequence, for example), you can rearrange them.
To reorder nodes in the diagram view:
1.
2.
613
614
1.
2.
3.
4.
5.
Double-click the modifier you want. For a description of each modifier, see Model
Group Properties in XML Schemas on page 655.
You can specify any number of modifiers in a complexType. Each modifier controls
the occurrence of its child nodes. You can specify the same modifier more than once.
For example, you might want to specify the sequence modifier, with some child nodes,
then the choice modifier with some child nodes, and then the sequence modifier again
with other child nodes.
6.
For each element that you want to define in this complexType with the selected
modifier, perform the following steps:
a.
b.
7.
c.
Type a name for the new element and press Enter. Stylus Studio displays a popup menu that lists the built-in simpleTypes and simpleTypes you defined.
d.
e.
In the Properties window, you can double-click the field for any property to set
the value for that property.
For example, you can specify 0 for the Min Occur. property and 1 for the Max
property. The effect is that the element is optional.
For each element or group that you want to refer to in this complexType with the
selected modifier, perform the following steps:
a.
b.
Group
c.
8.
9.
b.
c.
Type a name for the new attribute and press Enter. Stylus Studio displays a popup menu that lists the built-in simpleTypes and the simpleTypes you defined in
this schema.
d.
b.
c.
615
The letter element and salutation element have element and data children. You must
define complexTypes for both the letter and the salutation elements. Their Mixed
property value must be set to true. The Mixed property is the one that allows an element
to contain both elements (<shipDate>, for example) and raw data (Dear Mr. for example)
as children.
This section describes how to achieve this using both the Diagram and Tree views.
Diagram View
To define a complexType that mixes data and elements:
616
1.
2.
3.
Tree View
In the Tree view, to define a complexType that mixes data and elements:
1.
2.
3.
4.
5.
Double-click true.
6.
7.
Double-click the modifier you want. For a description of the modifiers, see Model
Group Properties in XML Schemas on page 655. For the rest of this procedure,
assume that you double-click the sequence modifier. By default, the elements that are
children of this node each appear exactly once. If you want an element to be optional,
or if you want an element to appear more than once, specify appropriate values for the
properties for minimum occurrence and maximum occurrence.
8.
a.
b.
Type a name for the new element and press Enter. Stylus Studio displays a popup menu that lists the built-in simpleTypes and any types already defined in the
schema.
c.
617
Diagram View
To define a complexType that contains only attributes:
1.
2.
3.
4.
618
5.
Make sure the new attribute is selected. In the Properties window, click the Data Type
field.
6.
7.
Repeat Step 3 through Step 6 for each attribute that you want to be in the group.
8.
9.
Tree View
To define a complexType that contains only attributes:
1.
2.
3.
4.
5.
Enter a name for the new attribute. Stylus Studio displays a scrollable, pop-up menu
that lists the built-in simpleTypes and any previously defined simpleTypes.
6.
7.
For each additional attribute you want to add to the group, click the name of the
attributeGroup in the Tree view, and repeat Step 4 through Step 6.
8.
9.
10.
11.
12.
619
Defining Elements That Carry Attributes and Contain Data in XML Schemas on
page 620
This element has a currency attribute, and it contains data based on the xsd:decimal
simpleType.
Diagram View
To define a complexType that contains only attributes:
620
1.
2.
The new element is added to the XML Schema. It is displayed in the diagram and in
the text pane (if you have it open). The properties for the new element are displayed
in the Properties window.
3.
Create a complexType of the element right-click the element and select Add >
ComplexType.
4.
5.
Click the QuickEdit button and select Derive by extension. This choice lets you
extend a base simpleType.
The Type Derivation dialog box appears.
Expand the W3C XML Schema and select the simpleType on which you want to base
the data allowed by the complexType.
7.
Click OK.
The XML Schema is updated with the elements new definition. Figure 304 shows an
extension of the decimal simpleType.
The simpleContent node ( ) specifies that the complexType can contain only data
and attributes. It cannot contain subelements.
8.
To add an attribute, right-click the element and select Add > Attribute.
621
Tree View
To define an element that contains raw data and carries attributes:
1.
2.
3.
Type the name of the element and press Enter twice. If you press Enter once, Stylus
Studio displays a pop-up menu that lists the possible types for the new element. You
need to define a new type, so you cannot select from this list. If the pop-up menu does
appear, press Enter or click outside the menu. You should now have a named element
with no type specified.
4.
5.
6.
In the drop-down list that appears, double-click simpleContent. This is the Content
Type property. When the content type is simpleContent, the complexType you are
defining can contain data and attributes. It cannot contain subelements.
7.
If you want the contained data to be one of the simpleTypes already defined with no
restrictions, click New Extension
in the left tool bar.
Stylus Studio displays a scrollable, drop-down list of the simpleTypes built in to XML
Schema and previously defined in the current schema.
8.
If you clicked New Extension, double-click the type of the data you want this element
to contain. Go to Step 9.
If you clicked New Restriction, follow these steps:
9.
622
a.
b.
c.
d.
e.
f.
To add another facet, click the restriction node for the simpleType, and repeat
Step b.
In the left tool bar, click the complexType node that you created in Step 4.
Stylus Studio User Guide
11.
Type a name for the new attribute and press Enter. Stylus Studio displays a scrollable,
drop-down list of the possible types for the new attribute.
12.
Double-click the attribute type. If you want to, specify a value for the attributes
Default or Fixed Value property in the Properties window.
13.
Define a top-level complexType. That is, it is a child of the xsd:schema node. In the
complexType definition, define the subelements. Elsewhere in the schema, define an
element that uses the complexType you defined.
Define an element that is a child of the xsd:schema node or a Model Group node. In
the element definition, define a complexType that contains your subelements.
To define a complexType that contains elements, see Defining complexTypes That
Contain Elements and Attributes Diagram View on page 610 or Defining
complexTypes That Contain Elements and Attributes Tree View on page 614.
Diagram View
To define an element and define subelements in the element definition:
1.
2.
3.
Right-click the new element and click QuickEdit. Select one of the following from the
QuickEdit menu:
623
Stylus Studio updates the element definition to include a complexType with the
sequence, choice, all, or any element you selected in the previous step.
4.
Tree View
In the Tree view, to define an element and define subelements in the element
definition:
1.
Click the Schema node or a Model Group (all, any, choice, sequence) node.
2.
3.
Enter the name for your new element. Stylus Studio displays a pop-up menu that lists
the built-in simpleTypes and any simple or complexTypes already defined in your
schema.
4.
Press Enter again. Rather that using a type that is already defined, you want to define
a new complexType in the definition of your element. You do not want to assign a type
to your new element.
5.
6.
At this point, the procedure for defining a complexType in the definition of an element is
the same as defining a complexType as a child of the Schema node. See Defining
complexTypes That Contain Elements and Attributes Tree View on page 614.
you define the identity constraint. If the element is present, the result must be unique
among the children of that element.
A key identity constraint specifies that the fields that form the expression must be
present in all instance documents. For example, if a key is based on date and number
attributes, the date and number attributes must always be specified.
A keyref identity constraint is equivalent to the IDREF attribute in DTDs. It specifies
that the contents of a field in the instance document is the value of a key that is defined
in another document. For example, a Quote document would have a reference to the
RFQ that originated it.
<element name="parts">
<complexType>
<sequence>
<element name="part" maxOccurs="unbounded">
<attribute name="number" type="SKU"/>
<attribute name="vendor" type="xs:string"/>
<attribute name="quantity" type="integer"/>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
625
In an XML document that uses this schema, you could define the following elements:
<purchaseReport>
<parts>
<part number="00-01-02" vendor="IBM" quantity="10"/>
<part number="01-01-02" vendor="BEAS" quantity="1"/>
...
</parts>
</purchaseReport>
If you want to enforce that there is just one part element for each product that has been
purchased, you add the following to the previous XML Schema example:
... [previous definition]
</sequence>
</complexType>
<unique name="pNumKey">
<selector xpath="parts/part"/>
<field xpath="@number"/>
<field xpath="@vendor"/>
</unique>
</element>
The schema validator starts with an initial context set that contains purchaseReport
elements. It runs the XPath expression parts/part to obtain the data set to be checked. In
this example, this is the two part elements. The schema validator then gathers the values
from the number and vendor attributes, and builds a key from these values. It then uses the
key to check that there are no part elements that have the same tuple.
Diagram View
To specify an identity constraint:
626
1.
Right-click the element for which you want to specify the identity constraint.
2.
Select Add > and then Key, KeyRef, or Unique from the menu.
3.
4.
In the Properties window, specify the XPath expression that identifies the set of
elements to which the identity constraint applies.
5.
In the Properties window, specify the XPath expression that identifies the element or
attribute for each element identified by the selector element that has to be unique.
Tree View
This topic provides the procedure for specifying an element with an identity constraint.
Introductory information about identity constraints is in Adding an Identity Constraint to
an Element on page 624. See also Example of an Identity Constraint on page 625.
To specify an identity constraint:
1.
Click the element for which you want to specify the identity constraint.
2.
3.
In the drop-down list that Stylus Studio displays, double-click unique, key, or keyref.
4.
In the Properties window, double-click the Name field and enter a name for the
identity constraint.
5.
If you selected keyref, then in the Properties window, double-click the Refer field and
enter the name of the key definition.
6.
In the tree representation, click the identity constraint you just defined.
7.
8.
In the drop-down list that Stylus Studio displays, double-click selector. You must
define exactly one selector for each identity constraint.
9.
In the Properties window, double-click the XPath Expression field and enter an
XPath expression that returns the element for which you are specifying a constraint.
10.
Click the unique, key, or keyref identity constraint you defined in Step 3.
11.
12.
In the drop-down list that Stylus Studio displays, double-click field. You must define
one or more fields for each identity constraint. A field can be whatever the XPath
expression (defined in the next step) retrieves.
13.
In the Properties window, double-click the XPath Expression field and enter an
XPath expression that returns the element or attribute that is the key or one of the keys
for the constraint. XPath expressions associated with fields return the data that define
the key for each element returned by the selector XPath expression.
14.
627
Specification of a group makes it easier to update the schema. You only need to update
the group definition. There is no need to change the references to the group.
Here is an example of an attributeGroup, deliveryDetail.
<xsd:attributeGroup name="deliveryDetail">
<xsd:attribute name="method"/>
<xsd:attribute name="vendor"/>
<xsd:attribute name="dateShipped"/>
<xsd:attribute name="dateArrived"/>
</xsd:attributeGroup>
628
1.
Define the elements that you want to be in the group. See Defining Elements and
Attributes in XML Schemas on page 619.
2.
3.
The new group is added to the XML Schema. It is displayed in the diagram and in the
text pane (if you have it open). The properties for the new group are displayed in the
Properties window.
4.
Specify the group name in the Name property in the Properties window.
5.
6.
In the shortcut menu, select Add > and then select the modifier for the group of
elements All, Choice, or Sequence. In the Properties window, click the fields for
the Min Occur. and Max Occur. properties to specify their values. These properties
determine how often the group of the elements with the selected modifier can appear.
7.
Drag the elements defined in Step 1 and drop them on the all, choice, or sequence
modifier created in Step 6.
Alternative
If you prefer, you can create the element group first, define the modifier for the group
elements, and then add new elements to the group by right-clicking on the modifier and
selecting Add > Element. If you do this, you must then define each of the elements you
added to the group.
Define the elements that you want to be in the group. See Defining Elements and
Attributes in XML Schemas on page 619.
2.
3.
4.
5.
6.
Double-click a modifier that applies to at least one element that will be in the group.
629
In the Properties window, double-click the fields for the Min Occur. and Max Occur.
properties to specify their values. These properties determine how often the subgroup
of the elements with the selected modifier can appear.
8.
For each element that you want to apply the selected modifier to, perform these steps:
9.
a.
b.
c.
To add more elements to the group and specify a different modifier for them, click the
name of the group in the Tree view, and repeat Step 5 through Step 8.
In any location where you can add a model group, you can also add a reference to a model
group definition.
630
1.
2.
3.
Make sure the new attribute is selected. In the Properties window, click the Data Type
field.
6.
7.
Repeat Step 3 through Step 6 for each attribute that you want to be in the group.
2.
3.
4.
5.
Type a name for the new attribute and press Enter. Stylus Studio displays a scrollable,
pop-up menu that lists the built-in simpleTypes and any previously defined
simpleTypes.
6.
7.
For each additional attribute you want to add to the group, click the name of the
attributeGroup in the Tree view, and repeat Step 4 through Step 6.
631
Comments
You cannot add comments in the Diagram tab.
To add comments in the Tree tab:
1.
2.
3.
Annotations
You use an annotation element to provide information about the XML Schema. You can
annotate any node in your XML Schema. The annotation element always contains at least
one appInfo or documentation node. Any text you want to enter must be entered in one of
these nodes.
Diagram View
When you create an annotation in the Diagram tab, you create the element and specify its
subelement (appInfo or documentation) in the Diagram tab. You can further describe the
node
632
2.
3.
Right-click the annotation icon and select the type of annotation you want to define
appInfo ( )or documentation (
).
4.
In the text pane, type the text for the appInfo or documentation node.
Stylus Studios backmapper identifies the line representing the element you created
in Step 3 in the text pane on the Diagram.
Tip
Tree View
To add an annotation:
1.
2.
3.
4.
If you added documentation, in the Properties window, double-click the Source field
and type the URL or file path for the documentation you want to include in the
schema, and press Enter.
Double-click the Language field and enter the language of the contents of the source
file.
5.
633
Example
In an XML Schema, you might have a comment node such as the following:
<xsd:schema ...>
<!-- The following element is .... -->
<xsd:element name="..."/>
The contents of a comment node have meaning only when a person reads them. However,
the contents of annotation nodes can be operated on. For example:
<xsd:schema ... >
<xsd:element name="foo">
<xsd:annotation>
<xsd:documentation language="en">
This is a <b>foo</b> element. Use it for ...
</xsd:documentation>
<xsd:documentation language="jp">
xksnjgfyre fvhfdbvhjds
</xsd:documentation>
</xsd:annotation>
</xsd:element>
...
You can apply an XSLT stylesheet to this XML Schema document. The stylesheet could
generate an HTML manual by extracting the Documentation nodes in the desired
language:
<xsl:stylesheet ... >
<xsl:template match="xsd:element">
<xsl:apply-templates select=
"xsd:annotation/xsd:documentation[@language='en']"/>
</xsl:template>
...
634
Defining Notations
Defining Notations
A notation is an unparsed entity. It is a name for something that you cannot express in
terms of XML. For example, suppose you have an XML file that represents a press
release. You can define a notation named logo that points to a JPEG image. You can place
the notation in the XML file in the location where you want the logo. See
http://www.w3.org/TR/REC-xml#Notations for more information on the notation element.
Note A notation element is always described as a child of the schema element.
Diagram View
To define a notation:
1.
2.
3.
Tree View
To define a notation:
1.
2.
3.
In the field that Stylus Studio displays, enter the name of the notation.
4.
In the Properties window, double-click the Public ID field and enter the public ID.
The public ID is a unique string that refers to the location of the external data, but it
leaves the resolution of the location to some interpretations, for example,
MyCompany//LOGO//JPEG.
5.
In the Properties window, double-click the System ID field and enter the system ID.
The system ID is the URL that Stylus Studio uses to physically locate the external
data, for example, http://www.mycompany.com/mylogo.jpg.
635
Including
Importing
Redefining
This section describes each of these techniques and how they can be used. In these
descriptions, we use the term referenced XML Schema to indicate the XML Schema that
is being included, imported, or redefined; and base XML Schema to indicate the XML
Schema in which the referenced schema is being included, imported, or redefined.
636
637
In the Diagram tab, Stylus Studio displays complete information for any definitions in
referenced XML Schema. You can toggle between diagram views of the base and
referenced XML Schemas using the definition browser.
If you select a referenced schema from the definition browser, as shown in Figure 306,
Stylus Studio changes the diagram view to display the referenced schemas structure. If
you selected a redefined XML Schema, for example, you could modify its complexType
definitions there.
What to Do Next
If you redefine an XML Schema (as opposed to including or importing one), you can
redefine nodes after referencing the XML Schema. See Redefining Nodes on page 641
for more information.
638
1.
2.
Specify the type of reference you want to make. If you are redefining an XML
Schema, specify the namespace in the Namespace field.
639
Specify the URL of the XML Schema you want to reference. For example:
myfile.xsd
http://www.mycompany.com/schemas/myfile.xsd
\\fileserver\schemas\myfile.xsd
6.
Click OK.
You are returned to the Referenced Schemas dialog box.
7.
2.
In the XML Schema left-side tool bar, click one of the following:
3.
4.
New Include
New Import
New Redefine
In the field that Stylus Studio displays, enter the location. This is a URL that identifies
the location of the file that contains the XML Schema. For example, it can be like any
one of the following:
myfile.xsd
http://www.mycompany.com/schemas/myfile.xsd
\\fileserver\schemas\myfile.xsd
If you defined an Import node, in the Properties window, double-click the Target
Namespace field and enter the target namespace. The target namespace must be
different from the target namespace of the importing file.
640
Redefining Nodes
Once you reference an XML Schema by redefining it, you are able to redefine that XML
Schemas complexTypes, simpleTypes, groups, and attributeGroups. This section
describes how to redefine nodes using the Diagram tab.
Restriction facets include length, minLength, maxLength, and totalDigits. For each facet
you specify, you provide the facet name, a value, and, for some facets, whether or not the
value is fixed. Note that not all facets apply to all types.
See About Facet Types for simpleTypes on page 607 for more information on facets.
641
2.
Select the node from the redefined XML Schema you want to redefine and click OK.
The redefined node is added to the diagram, and the text for the redefined node
appears in the text pane. For example, <xsd:complexType name="PublicationType"/>.
4.
5.
From the shortcut menu, select Quick Edit > and then either Derive by extension or
Derive by restriction.
The Type Derivation dialog box appears.
642
Select the base type from which you want to derive the definition of the node you are
redefining. and click OK.
The node you added in Figure 3 is modified in the diagram to display the restriction
or extension you are using to redefine it, as shown in Figure 312.
The code displayed in the text pane is also modified. For example:
<xsd:complexType name="PublicationType">
<xsd:simpleContent>
<xsd:restriction base="SKU"/>
</xsd:simpleContent>
</xsd:complexType>
7.
643
644
Information about the XML Schemas properties, such as its target namespace and
any declared namespaces
Global declarations and global definitions, if any
A legend that describes the graphical conventions used in the XML Schema
documentation. The legend uses a fictitious type declaration for example purposes.
A glossary that defines terminology used in the XML Schema documentation.
Tip You can hide the legend and the glossary by clicking the Printer-friendly Version check
645
Customize and modify the XML Schema documentation. For example, you can
choose to include all super-types, you can change the default name, and you can
specify the sort order. Settings for these and other properties that affect the content
and appearance of the XML Schema documentation are displayed in the Options
dialog box. See XS3P Stylesheet Settings on page 646 for more information.
Title The default title is XML Schema Documentation, but you can change it to
whatever you want by editing the Title field.
Sort order By default, Stylus Studio sorts information in the XML Schema in
alphabetical order by type name. If you want to display information in document
order, set the Sort by Component field to False.
Whether or not you want Stylus Studio to search included and imported XML
Schemas.
If you want to incorporate instructions in the HTML, the Use JavaScript option
makes it easy for you to add instructions such to display pop-up windows and hide
information in the generated HTML document.
Supertypes
Subtypes
Glossary
Legend
Schema diagrams
646
You control these settings on the Documentation page of the Options dialog box.
Tip You can also modify the stylesheet directly. See Modifying the XS3P Stylesheet on
page 647.
If you are using the XS3P stylesheet, optionally click the Printer-friendly Version
check box at the top of the XML Schema documentation.
2.
Review the settings on the Documentation page of the Options dialog box (Tools >
Options > Module Settings > XML Schema Editor > Documentation).
3.
Optionally, preview the XML Schema documentation (File > Print Preview).
4.
), or type Ctrl + P.
647
648
Description
Type
Namespace
The namespace for the Schema node is usually xsd, but you can
change it.
Target Namespace
649
Description
Default Attribute
Form
<xs:schema elementFormDefault="qualified"
targetNamespace="http://myNs"
xmlns:myns="http://myNS">
<xs:element name="topElem">
....
</xs:element>
<xs:element name="anElem">
<xs:complexType>
<xs:sequence>
<xs:element ref="myns:topElem">
...
If the form for the element topElem (or, the default form for
elements) was defined to be unqualified, the reference could
have used ref="topElem".
Default Blocked
Definitions
Default Final
If an element does not have its own blocked or final definition, the
schema processor uses the default blocked or final definition you
specify here.
Definitions
650
Description
Type
Name
The tag name you use in an instance document. Specify the name
you want the element to have.
Min Occur.
Max Occur.
Data Type
The type of the data that the element contains. Select from all
simpleTypes defined in an XML Schema, and all types (simple or
complex) that you define in the same schema. Nodes that are
references to elements do not have this property.
Default
651
Description
Fixed Value
When you specify a value for Fixed Value, it is optional for the
element to appear in an instance document. However, if the element
does appear, it must have the value specified by Fixed Value.
Whether or not you specify this element in an instance document,
the schema processor behaves as though you had specified this
element with the fixed value. An element can have a value for the
Fixed Value property or a value for the Default property. The two
properties are mutually exclusive.
Abstract
Nillable
Form
Blocked
Defines that this element cannot be derived in some forms. That is,
it specifies that one or more extensions, restrictions or substitutions
cannot be permitted. For example, an enumeration for all the states
in the United States can block extensions and substitutions, thus
allowing derived data types only so as to restrict the number of valid
states.
Substitutions
652
Description
Final Substitutions
Substitution Groups
Description
Type
Name
Data Type
The type of the data that is the value of the attribute. Select from all
simpleTypes defined in an XML Schema, and all simpleTypes that
you already defined in the same schema. References to attributes do
not have this property.
653
Description
Default
654
Fixed Value
When you specify a value for Fixed Value, it is optional for the
attribute to appear in an instance document. However, if the attribute
does appear, it must have the value specified by Fixed Value.
Whether or not you specify this attribute in an instance document,
the schema processor behaves as though you had specified this
attribute with the fixed value. An attribute can have a value for the
Fixed Value property or a value for the Default property. The two
properties are mutually exclusive.
Restrictions
Form
Description
Type
Name
Min Occur.
Max Occur.
655
model group references and defines elements. Model groups have the properties described
in Table 74:
Table 74. Model Group Properties
Property
Description
Type
Modifier
Specifies the occurrence rules for the elements that you add as
children of the model group node. Specify one of the following
values:
all specifies that each element must appear exactly zero or one
time. The elements can appear in any order. In an instance
document, the children of the group or complexType can
include 0 or 1 instance of each element.
which they are specified in the schema. For each element, you
can specify whether it is optional and whether it can appear
more than once. The default is that exactly one must be present
in an instance document. In an instance document, each element
that appears must be in the same order as in the schema.
Another value you can specify is any. When you specify any,
you do not add any element definitions or references to
elements. As the name implies, any element can appear any
number of times.
656
Min Occur.
Max Occur.
Description
Type
Name
The type name you use elsewhere in the XML Schema. Specify the
name you want the type to have.
Abstract
Mixed
Blocked
Defines that this type cannot be derived in some forms. That is, it
specifies that one or more extensions, restrictions or substitutions
cannot be permitted. For example, an enumeration for all the states
in the United States can block extensions and substitutions, thus
allowing derived data types only so as to restrict the number of valid
states.
Substitutions
Final Substitutions
657
Description
Type
Base Type
658
Property
Description
Type
Mixed
A Boolean value that indicates whether this node can contain text as
well as elements.
Content Type
Description
Type
Aggregator Type
659
Description
Facet Type
Fixed
A Boolean value that indicates whether you can further restrict the
simpleType with this same facet and a different value. The default is
false. That is, the default is that you can apply the same facet more
than once. For example, suppose you specify the following
definition:
<xsd:simpleType name="zip">
<xsd:restriction base="xsd:string">
<xsd:length value="5" fixed="true"/>
</xsd:restriction>
</xsd:simpleType>
660
Varies according to the facet type. See About Facet Types for
simpleTypes on page 607.
Description
Type
Name
Public ID
Unique string that refers to the physical location of the external data,
for example, MyCompany//LOGO//JPEG.
System ID
Description
Type
Location
URL that identifies the location of the file that contains the XML
Schema.
661
have the properties described in Table 82. See Referencing External XML
Schemas on page 636 for more information.
Description
Type
Location
URL that identifies the location of the file that contains the XML
Schema.
Target Namespace
Description
Type
Location
URL that identifies the location of the file that contains the XML
Schema.
662
Property
Description
Type
Name
Description
Type
XPath Expression
An XPath expression that returns the element for which you are
defining a constraint.
Description
Type
Source
Language
663
664
Chapter 9
This section provides information about how to use the Stylus Studio Document Type
Definition (DTD) editor to define a DTD. Familiarity with DTDs is assumed.
This section discusses the following topics:
665
What Is a DTD?
A document type definition (DTD) describes the structure of a document. It specifies
which elements can contain which other elements, which elements are optional and which
are required, and which elements contain data. For example, a DTD might specify that a
book element
A document instance is an XML document that uses a particular DTD. In other words, the
contents of a document instance have been tagged according to the structure defined in
the DTD it is associated with. For example, if the contents of the bookstore.xml file follow
the structure defined in the bookstore.dtd file, bookstore.xml is a document instance of
the bookstore DTD.
Creating DTDs
To create a DTD, select File > New > DTD Schema from the Stylus Studio menu bar.
Stylus Studio displays the DTD schema editor.
The Stylus Studio DTD editor provides two views of a DTD. In the Tree view, Stylus
Studio uses branches and leaves to represent the DTD. When you define a DTD in the Tree
view, you do not need to know the details about DTD syntax. In the Text view, Stylus
Studio displays the lines of text that make up the DTD. To define a DTD in the Text view,
you must be familiar with DTD syntax.
If you are editing an XML document and you want to create a DTD for that document,
click the Schema tab. Stylus Studio displays the Schema Not Found dialog box. Indicate
666
that you want Stylus Studio to generate a DTD and indicate whether you want the new
DTD to be internal or external. After you respond to the prompts and click Yes, Stylus
Studio automatically creates the DTD for you and displays it in the Schema tab.
If you instruct Stylus Studio to create an internal DTD, you can update the DTD in the
XML editor. If you instruct Stylus Studio to create an external DTD, you must explicitly
open it to update it. An external DTD that Stylus Studio displays in the Schema tab is
read-only.
To use Stylus Studio to validate an XML document against a DTD, see Validating XML
Documents on page 208. If you update a DTD in Stylus Studio and that DTD is
associated with an XML document that is open in Stylus Studio, Stylus Studio refreshes
the schema information for the XML document.
Restrictions
A DTD can include other, external DTDs. In a future release, it is expected that you will
be able to click Open Schema
to display an included DTD. However, in this release,
this is not supported.
667
DTDs are not XML documents. Consequently, as you would expect, Indent XML Tags
does not work on DTDs.
Aggregating Modifiers to Allow Any Order and Any Number in DTDs on page 670
668
Modifier
Description
Indicator in DTD
Optional
Zero or more
Asterisk (*)
One or more
Description
Indicator in DTD
Choice
Sequence
Comma (,)
author
title
Zero or More
#PCDATA
author
Zero or More
#PCDATA
In the book element definition, Sequence modifies book and One or More modifies Sequence.
Because the title element immediately follows the Sequence modifier, the default
occurrence rule is assumed. That is, the title element must appear exactly once. In the
Text view of the DTD, the definition for the book element is as follows:
<!ELEMENT book (title, (author)+)>
669
In the Text view of the DTD, the definition for the book element is as follows:
<!ELEMENT book (title, (author|editor)?, paragraph*)>
670
When you define elements in the Text tab, you must know the syntax and keywords for
what you want to define. This information is publicly available on the World Wide Web.
Stylus Studio documentation does not include instructions for defining a DTD in the Text
tab. For DTD information, see, http://www.w3.org/TR/REC-xml.
When you use Stylus Studio, it is easier to define an element in the Tree tab. In the Tree
, and Stylus Studio takes care of the syntax and
tab, you click New Element Definition
keywords. In the Tree tab, definition of an element requires that you
1.
Create the element by specifying its name. To do this, see Defining Elements in the
DTD Tree Tab on page 672, which is the first topic in this section.
2.
Define the structure of the element by specifying modifiers, defining where raw data
is allowed, and adding references to other elements. To help you do this, this section
discusses the following topics:
671
2.
3.
Type the name of the new element and press Enter. Stylus Studio displays the
properties for the new element in the Properties window. If the Properties window is
not visible, select View > Properties from the Stylus Studio menu bar. For example,
suppose you specified title as the name of the new element. Your new element has
the following properties:
Table 88. Element Properties
672
Property
Value
Type
Element
Name
title
Content Model
Empty
To change the value of a property, double-click the current value. For information
about the properties that each element can have, see About Node Properties in
DTDs on page 684.
After you create an element, you must define the structure of the contents of the element.
The rest of the topics in this section provide information on how to define structure.
Click the name of the element that you want to have an attribute.
2.
3.
Define the element that you want to be required. See Defining Elements in the DTD
Tree Tab on page 672.
2.
Create the element that contains the element that you want to be required. This is the
container element.
3.
4.
5.
Double-click Sequence.
6.
If the required element can appear only once, skip this step. If the required element
can appear more than once, click New Modifier and double-click One or More in the
pop-up menu.
7.
673
Enter the name of the element that you want this element to reference.
After you add a reference to an element, you might want to check the definition of the
referenced element. To do this, right-click the reference. In the shortcut menu, click
Go To Definition. Stylus Studio moves the focus to the definition of the referenced
element.
For example, suppose the title element is required, and that it is relevant only in the
context of a book element. When you define the book element, you specify that it contains
the title element. If you specify only the Sequence modifier, the occurrence default is
assumed. The occurrence default is that there must be exactly one of the contained
element. In other words, the title element is required and there can be only one. In this
case, the definition of the book element is as follows:
<!ELEMENT book (title)>
It is also possible for an element to be required and for more than one to be allowed.
Suppose the book element must also contain at least one author element, but it can contain
more than one author element. The definition of the book element is as follows:
<!ELEMENT book (title, author+)>
Define the element that you want to be optional. See Defining Elements in the DTD
Tree Tab on page 672.
2.
Create the element that contains the element that you want to be optional. This is the
container element.
3.
4.
5.
If the container element can contain only the optional element, skip this step. If the
container element can contain more than one element, click Sequence.
6.
7.
8.
One or more
In the Tree tab, to specify that there can be multiple instances of an element:
1.
Define the element that can appear multiple times. See Defining Elements in the
DTD Tree Tab on page 672.
2.
Define the element that contains the element that can appear multiple times. This is
the container element.
675
4.
5.
If the container element can contain only one type of element, skip this step. If the
container element can contain more than one type of element, double-click
Sequence, and then click New Modifier.
6.
Double-click Zero or More to allow the container element to contain zero, one, or
more instances of an element. Or, double-click One or More to allow the container
element to contain one or more instances of an element.
7.
Suppose there are some elements that can appear zero, one, or more times, and there are
other elements that can appear one or more times. The tree representation for this might
look like the following:
book
Sequence
One or More
Author
Format
Zero or More
Award
Review
In this example, an instance document must contain these elements in the following order:
author
format
award
review
676
Define the elements that your new element can contain. See Defining Elements in
DTDs on page 671.
2.
Define the element that you want to contain another element. This is the container
element.
3.
4.
5.
Double-click Choice.
677
For each element in the group of elements from which one element can appear:
a.
When the XSLT processor validates an instance document against this DTD, it ensures
that each instance of the new element you just defined contains exactly one of the
referenced elements.
The tree representation for an InventoryNumber element that can contain a book, magazine,
or newsletter element would look like the following:
InventoryNumber
Choice
book
magazine
newsletter
678
1.
Define the elements that you want your new element to contain. See Defining
Elements in DTDs on page 671.
2.
Define the element that contains the sequence of elements. This is the container
element.
3.
4.
5.
Double-click Sequence.
To add required elements to the container element, click New Reference to Element
in the left tool bar and enter the name of the required element. Do this for each
required element. You can change the order later.
Optional elements
Elements that belong to a group in which only one element in the group can be present
The procedure is the same for these modifiers. The only difference is the modifier you
select. For example, following are the instructions for adding optional elements:
1.
2.
3.
Double-click Optional.
4.
For each optional element, click New Reference to Element and enter the name of the
optional element. This works only if you want all optional elements to be consecutive.
If you want optional elements to be interspersed with required elements or elements
that can appear one or more times, you must perform steps 1 through 4 for each
element.
In an instance document, the contained elements must appear in the order in which they
are specified in the DTD.
To modify the order:
1.
2.
Click the up or down arrow repeatedly until the element is where you want it to be.
To move a required element that can appear only once, click its name and then use the up
and down arrows.
Alternative: Right-click the item you want to move. Select Move Up or Move Down from
the shortcut menu.
679
2.
3.
4.
To delete a node in the DTD, right-click the node you want to delete. In the shortcut menu
that appears, click Delete.
Alternative: Click Delete Node
680
General entities are useful for things that change often, such as the name of a product in
development. An entity allows you to change the value in one place and have the corrected
value appear everywhere it is needed.
See also Description of Entity and Parameter Entity Properties in DTDs on page 687.
When you define a general entity, you specify a symbol that you can use in instance
documents. When the XML parser finds a reference to a general entity, it replaces the
symbol with the value you specified when you defined the general entity.
When you define a parameter entity, you specify a symbol that you can use elsewhere in
the DTD. Again, when the XML parser finds a reference to a parameter entity, it replaces
the reference with the value you specified when you defined the parameter entity.
In a DTD, the definition of an entity must appear before a reference to that entity.
Therefore, it is good practice to put all entity declarations at the beginning of a DTD.
This section discusses the following topics:
2.
3.
Type the name of the new entity and press Enter. Stylus Studio displays the properties
for the new entity in the Properties window. If the Properties window is not visible,
select View > Properties from the Stylus Studio menu bar to display it.
4.
681
If the value of the Location property is External, skip this step. If the value of the
Location property is Internal, double-click the Value field and enter the value of the
entity. Definition of your entity is complete. You do not perform the remaining steps
in this procedure.
6.
If the value of the Location property is External, specify a value for System ID.
Double-click the field to enter a value. The value of System ID is a path to a file. It
can be a URL or a file system path.
Although you can also specify a value for the Public ID property, Stylus Studio
ignores any value you specify. A Public ID is a string that some parsers can resolve to
an address, which they then use to locate a file. Stylus Studio does not have this
capability.
7.
If you are defining a parameter entity, you are done. If you are defining a general
entity, check the value of the Parsed property. If necessary, double-click the value of
the Parsed property to change it. The value of the Parsed property indicates whether
the value of the entity is parsed XML. For example, if the entity refers to an image
file, you do not want Stylus Studio to try to parse it.
In an instance document, when the XML parser finds &shopname;, it replaces it with Most
Excellent Book Store of Tokyo.
682
The percent sign (%) after the ENTITY keyword indicates that this is a parameter entity.
Later in the DTD, you can reference this parameter entity as follows:
<!ELEMENT invoice (%customer;, item, price, date)>
2.
3.
4.
2.
683
4.
Element
Attribute
DTD Modifier
PCDATA
Entity
Parameter Entity
Text
Comment
To determine the properties for a particular node in a DTD, click the node. Stylus Studio
displays the properties in the Properties window. If the Properties window is not visible,
select View > Properties from the Stylus Studio menu bar.
To change a property, double-click the property value in the Properties window. Enter the
new value or, if a drop-down menu appears, double-click the value you want. Any changes
you make in the Properties window are immediately reflected in the Tree and Text views.
You cannot change the type property of a node.
The remainder of this section discusses the following topics:
684
Description
Empty
Element Only
Mixed
Any
Allowable Values
Description
Type
Attribute
Name
String
Restrictions
Fixed
Implied
Optional
685
Content Type
686
Allowable Values
Description
Required
CDATA
Entity
Entities
Enumerated
ID
IDREF
IDREFs
NMToken
Allowable Values
Description
NMTokens
Notation
Allowable Values
Description
Type
Entity
Parameter Entity
Name
String
Location
External or
Internal
String
687
Allowable Values
Description
Public ID
String
System ID
String
Parsed
True or False
Replace root_element_name with the name of the root element in your XML document.
Replace path_to_dtd with the path for the DTD you want your document to use.
688
1.
In the Text tab of the DTD editor, in the DOCTYPE element, select only the text inside
the brackets [ ].
2.
3.
Select File > New > DTD Schema from the menu bar.
4.
Paste the text in the new DTD schema file that Stylus Studio displays.
5.
Save the file. You might want to save the DTD in the same directory as the XML
document that uses it.
In your XML document in the Text tab of the DTD editor, remove the brackets and
insert the following in their place:
SYSTEM "schema_file_path"
The path you specify can be the relative or absolute path of the DTD file you just
saved. This path must be in quotation marks.
689
690
Chapter 10
The XML Path Language (XPath) allows you to query an XML document using XPath
expressions. An XPath expressions returns a well-formed XML node-list or an XPath
value object. Stylus Studio supports the November 2005 W3C XPath 2.0 Candidate
Recommendation. XPath 2.0 is a superset of XPath 1.0.
This section discusses the following topics:
691
About XPath
XPath is a notation for retrieving information from a document. The information could be
a set of nodes or derived values.
XPath allows you to identify parts of an XML document. In addition, a subset of XPath
allows you to test whether or not a node matches a particular pattern. XPath provides
Boolean logic, filters, indexing into collections of nodes, and more.
XPath is declarative rather than procedural. You use a pattern modeled on directory
notation to describe the types of nodes to look for. For example, book/author means find
all author elements that are contained in book elements.
XPath provides a common syntax for features shared by Extensible Stylesheet Language
Transformations (XSLT) and XQuery. XSLT is a language for transforming XML
documents into XML, HTML, or text. XQuery builds on XPath and is a language for
extracting information from XML documents.
692
The basic syntax for XPath mimics the Uniform Resource Identifier (URI) directory
navigation syntax. However, the syntax does not specify navigation through a physical file
structure. The navigation is through elements in the XML tree.
Benefits of XPath
XPath is designed for XML documents. It provides a single syntax that you can use for
queries, addressing, and patterns. XPath is concise, simple, and powerful. XPath has
many benefits, as follows:
Query strings are easily embedded in programs, scripts, and XML or HTML
attributes.
You can specify any path that can occur in an XML document and any set of
conditions for the nodes in the path.
Query conditions can be evaluated at any level of a document and are not expected to
navigate from the top node of a document.
For programmers, queries are declarative, not procedural. They say what should be
found, not how it should be found. This is important because a query optimizer must
be free to use indexes or other structures to find results efficiently.
693
Internationalization
Queries can contain non-Latin characters.
Restrictions on Queries
XPath is a language for selecting existing XML data; it does not perform manipulation
(like sorting) or construction of different XML structures. To perform such operations,
you need to use the language that is hosting XPath XSLT or XQuery, for example.
You cannot query non-XML data. If you query a document that does not contain XMLformatted data, Stylus Studio displays an error message that informs you that the queried
text is not XML.
694
The XPath Query Editor is a dockable window that you can use to query XML documents
in Stylus Studio. An example, showing an XPath expression being evaluated against
bookstore.xml from the Example project installed with Stylus Studio, is shown here:
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the XPath Query
Editor video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
A query pane, in which you enter the XPath expression you want to execute against
the current document. The query pane allows you to enter queries with multiple lines.
695
The query pane supports Stylus Studios Sense:X feature, which provides tool-tips for
XPath expressions and auto-completion for XML documents associated with an
XML Schema, as shown here:
A results pane, which shows the results from the query after you execute it. Results
are shown as a number of hits and include the type of XML tag and value of each hit.
When you click on a returned node, Stylus Studio moves the cursor in the XML
document to the source node for the returned node.
A namespace pane, which allows you to redefine the namespace prefix to be used in
the query. The namespace pane is not displayed by default, and is not shown in
Figure 316.
696
Click the Show XPath Query Editor button on the XML Editor tool bar ( ).
The XPath Query Editor appears. Any previously created queries are displayed on
individual tabs. If no queries have been created, a new tab, labeled Query1, is
displayed.
Alternative:
Select View > XPath Query Editor from the Stylus Studio menu.
Click Tools > Options > General > Editor Format to display the Editor Format page
of the Options dialog box.
The Options dialog box appears.
2.
Scroll the Colors list; fields related to the XPath Query Editor are prefixed with
XPath.
3.
4.
Click OK.
You can create up to sixty-four queries for a single document; each is given the name
Queryn, where n is a unique number incremented by one. You cannot name queries.
Queries are saved with the project. Changes you make either to query expressions, or
creating and deleting queries are saved when you save the project, and not the document.
697
Click the Execute button on the XPath Query Editor tool bar (
).
Stylus Studio processes the query and displays the result in the results pane.
Alternatives:
Press F5.
or
Right-click the query panel in the XPath Query Editor and select Execute Query from
the short cut menu.
Click the New XPath Query button on the XPath Query Editor tool bar (
A new tab appears in the XPath Query Editor.
).
Alternative:
Right-click the query panel in the XPath Query Editor and select New XPath Query
from the short cut menu.
Deleting a Query
To delete a query:
Click the Delete button on the XPath Query Editor tool bar (
).
The tab associated with the query is removed from the XPath Query Editor. The query
itself is deleted when you save the project.
Alternative:
Right-click the query panel in the XPath Query Editor and select New XPath Query
from the short cut menu.
698
When you click on a result node, Stylus Studios back-mapping feature highlights the line
in the XML document that supplied the value for the result node you selected.
Click the Open result in a new XML document button on the XPath Query Editor tool
bar (
).
699
Alternative:
Right-click the query pane in the XPath Query Editor and select Open result in a new
XML document from the shortcut menu.
In addition to the namespace URI, Stylus Studio displays the namespace prefix declared
in the XML document, if any, and a prefix that is used when creating XPath query
expressions.
If one namespace prefix clashes with another in the XML document, Stylus Studio
renames the second prefix by adding a number to the end of the original prefix name to
make it unique for example, if two namespaces have the prefix bks, the second is
renamed bks1. Similarly, if no namespace prefix has been declared, Stylus Studio creates
a default namespace prefix, ns1. Namespace declarations in the XML document are not
changed.
Namespace prefixes defined for the query
Allow you to execute the query with the root node of the document as the current
context node
2.
Comment...
Element...
Processing
Instruction...
Comment...
Document
Element
Processing
Instruction...
Text...
701
The root node has no actual text associated with it. You can think of the file name as the
root node. A document can include zero or more comments and zero or more processing
instructions.
A document element is required, and there can be only one. The document element
contains all elements in the document. For example:
bookstore.xml
specialty
="novel"
<book>
<bookstore>
<book>
<magazine>
<my:book>
xmlns:my="http://www.placeholder-name-here.com/schema/"
In the preceding figure, bookstore.xml is the name of a file that contains XML data. There
is a comment near the beginning of the document that starts with "This file represents
a ..." The document element is bookstore. The immediate children of bookstore include
an attribute, a namespace declaration (not supported by Stylus Studio), three book
elements (one is in the my namespace), and a magazine element. The book and magazine
elements contain elements and attributes, which are shown in the figure that appears in
Tree Representation of a Sample XML Document on page 704.
702
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<publication>
Selected Short Stories of
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<price>14</price>
</publication>
</author>
<pub_date>1994-07-21</pub_date>
<price>55</price>
</book>
<magazine style="glossy" frequency="monthly">
<title>Tracking Trenton</title>
<price>2.50</price>
<subscription price="24" per="year"/>
</magazine>
703
<first-name>Toni</first-name>
<last-name>Bob</last-name>
<degree from="Trenton U">B.A.</degree>
<degree from="Harvard">Ph.D.</degree>
<award>Pulitzer</award>
<publication>Still in Trenton</publication>
<publication>Trenton Forever</publication>
</author>
<price intl="canada" exchange="0.7">6.50</price>
<excerpt>
704
continued in Figure 321). To use Stylus Studio to view a similar tree for any XML
document, open the XML document in Stylus Studio and select the Tree tab.
705
706
In Stylus Studio, open bookstore.xml. You can find it in the examples directory of your
installation directory.
2.
Open the XPath Query Editor if it is not already displayed. See Displaying the XPath
Query Editor on page 696 if you need help with this step.
3.
4.
).
Obtaining All Elements of a Particular Name from a Particular Branch on page 710
707
Start at the
root node.
This query returns the bookstore element. Because the bookstore element is the document
element, which contains all elements and attributes in the document, this query returns all
marked-up text.
In the query, the initial forward slash (/) instructs the XPath processor to start its search at
the root node.
Suppose you run the following query on bookstore.xml:
/book
This query returns an empty set. It searches the immediate children of the root node for
an element named book. Because there is no such element, this query does not return any
marked-up text. Note that this query does not return an error. The query runs successfully,
but the XPath processor does not find any elements that match the query. All book
elements are grandchildren of the root node, and the XPath processor only checks the
children of the root node.
708
The following figure shows how the XPath processor interprets the /bookstore/book
query:
/ bookstore / book
Search immediate
children for the
bookstore element.
This is a
separator
between
When the XPath processor starts its search at the root node, there is only one element
among the immediate children of the root node. This is the document element. In this
example, bookstore is the document element.
The query in this figure returns the book elements that are children of bookstore. This
query does not return the my:book element, which is also a child of bookstore.
Now you can define queries that obtain any elements you want. For example:
/bookstore/book/title
This query returns title elements contained in book elements that are contained in
bookstore.
The double forward slash (//) at the beginning of a query instructs the XPath processor to
start at the root node and search the entire document. In other words, the XPath processor
searches all descendants of the root node.
If you perform this query on bookstore.xml, it returns the last-name elements that are
children of author elements, and it also returns the last-name element that is a child of a
publication element.
709
This query returns all price elements that are contained in book elements. Some of these
price elements are immediate children of book elements. One returned price element is a
great-grandchild of the second book element. The following figure shows how the XPath
processor interprets this query:
/ bookstore / book // price
Start at the
root node.
710
Search
immediate
children for the
bookstore
This is a
step
separator.
Search
immediate
children of
bookstore
for book
/ bookstore / author
Start at
the
root
node.
Search
immediate
children
for the
bookstore
element.
This is a step
separator.
Search all
descendants of
bookstore.
Search
immediate
children of
bookstore.
Return all
author
elements.
/ bookstore // author
This query does return all titles of books, but it also returns the title of a magazine. This
query instructs the XPath processor to start at the root node, search all descendants, and
return all title elements. In bookstore.xml, this means that the query returns the title of
the magazine in addition to the titles of books. In some other document, if all titles are
contained in book elements, this query returns exactly what you want.
To query and obtain only the titles of books, you can use either of the following queries.
They obtain identical results. However, the first query runs faster.
/bookstore/book/title
//book/title
The first query runs faster because it uses the child axis, while the second query uses the
descendent-or-self axis. In general, the simpler axes, such as child, self, parent, and
Stylus Studio User Guide
711
are faster than the more complicated axes, such as descendent, preceding,
following, preceding-sibling, and following-sibling. This is especially true for large
documents. Whenever possible, use a simpler axis.
This query returns the style attributes associated with the magazine, the three books, and
the my:book element. That is, it returns all the style attributes in the document. It does not
return the elements that contain the attributes.
Following is another query that includes an attribute:
/bookstore/book/@style
This query returns the three style attributes for the three book elements.
The following query returns the style attribute of the context node:
@style
If the context node does not have a style attribute, the result set is empty.
The next query returns the exchange attribute on price elements in the current context:
price/@exchange
Following is an example that is not valid because attributes cannot have subelements:
price/@exchange/total
Following is a query that finds the style attribute for all book elements in the document:
//book/@style
712
Restrictions
Attributes cannot contain subelements. Consequently, you cannot apply a path operator to
an attribute. If you try to, you receive a syntax error.
Attributes are inherently unordered. Consequently, you cannot apply a position number to
an attribute. If you try to, you receive a syntax error.
Start at the
root node.
Search
immediate
children for
the
bookstore
Step
separator.
Search
immediate
children of
bookstore for
book
Check book
elements
against the
subquery in
Return only
those book
elements that
contain title
child elements
that contain
End
filter.
This query checks each book element to determine whether it has a title child element
whose value is "History of Trenton". If it does, the query returns the book element. Using
the sample data, this query returns the second book element.
The following topics provide details about filters:
713
If you need to specify this filter as part of an attribute value, use single quotation marks
instead of double quotation marks. This is because the attribute value itself is (usually)
inside double quotation marks. For example:
<xsl:value-of select="/bookstore/book[title='History of Trenton']">
Strings within an expression may contain special characters such as [, {, &, , /, and others,
as long as the entire string is enclosed in double quotes ("). When the string itself contains
double quotes, you may enclose it in single quotes ('). When a string contains both single
and double quotes, you must handle these segments of the string as if they were individual
phrases, and concatenate them.
The next query returns author elements if the author has a degree:
//author[degree]
The next query returns the date attributes that match "3/1/00":
//@date[.="3/1/00"]
The next query returns manufacturer elements in the current context for which the rwdrive
attribute of the model is the same as the vendor attribute of the manufacturer:
manufacturer[model/@rwdrive = @vendor]
714
The next query returns all titles of books in the current context that have at least one
excerpt:
book[excerpt]/title
Multiple Filters
You can specify any number of filters in any level of a query expression. Empty filters
( [ ] ) are not allowed.
A query that contains one or more filters returns the rightmost element that is not in a filter
clause. For example:
book[excerpt]/author[degree]
The previous query returns author elements. It does not return degree elements. To be
exact, this query returns all authors who have at least one degree if the author is of a book
for which the document contains at least one excerpt. In other words, for all books in the
current context that have excerpts, this query finds all authors with degrees.
The following query finds each book child of the current context that has an author with
at least one degree:
book[author/degree]
The next query returns all books in the current context that have an excerpt and a title:
book[excerpt][title]
715
The following query returns all book children in the current context with style attributes:
book[@style]
The next query finds all book child elements in the current context in which the value of
the style attribute of the book is equal to the value of the specialty attribute of the
bookstore element:
book[/bookstore/@specialty = @style]
Wildcards in Queries
In a query, you can include an asterisk (*) to represent all elements. For example:
/bookstore/book/*
This query searches for all book elements in bookstore. For each book element, this query
returns all child elements that the book element contains.
The * collection returns all elements that are children of the context node, regardless of
their tag names.
The next query finds all last-name elements that are grandchildren of book elements in the
current context:
book/*/last-name
The following query returns the grandchild elements of the current context.
*/*
716
Restrictions
Usually, the asterisk (*) returns only elements. It does not return processing instructions,
attributes, or comments, nor does it include attributes or comments when it maintains a
count of nodes. For example, the following query returns title elements. It does not
return style attributes.
/bookstore/book/*[1]
Wildcards in strings are not allowed. For example, you cannot define a query such as the
following:
/bookstore/book[author=" A* "]
Attributes
To use a wildcard for attributes, you can specify @*. For example:
/bookstore/book/@*
For each book element, this query returns all attributes. It does not return any elements.
In format descriptions, a question mark that follows an argument indicates that the
argument is optional. For example:
string substring(string, number, number?)
This function returns a string. The name of the function is substring. This function takes
two required arguments (a string followed by a number) and one optional argument (a
number).
Stylus Studio User Guide
717
This query returns an empty set because the name of the document element is bookstore
and not Bookstore.
Blank spaces in queries are not significant unless they appear within quotation marks.
718
XPath Operators
Grouping
( )
Filter
[ ]
Unary minus
Multiplication
*, div, mod
Addition
+, -
Relational
(Comparison)
Union
Negation
not
Conjunction
and
Disjunction
or
XPath Operators
Sequence separator
Conjunction
and
Type matching
instance of
Assertion
treat
Conversion test
castable
Conversion
cast
719
XPath Operators
Relational
(Comparison)
eg, ne, lt, le, gt, ge, =, !=, <, <=, >, >=,
is, <<, >>
Range
to
Addition
+, -
Multiplication
Unary
unary -, unary +
Union
union, |
Select set
intersect, except
Navigation
/, //
Filter
[ ]
720
Axis
An axis specifies a list of nodes in relation to the context node. For example, the ancestor
axis contains the ancestor nodes of the context node. The child axis contains the
immediate children of the context node. See Syntax for Specifying an Axis in a Query
on page 727.
Context Node
A context node is the node the XPath processor is currently looking at. The context node
changes as the XPath processor evaluates a query. If you pass a document to the XPath
processor, the root node is the initial context node. If you pass a node to the XPath
processor, the node that you pass is the initial context node. During evaluation of a query,
the initial context node is also the current node.
Current Node
Current node is the node that the XPath processor is looking at when it begins evaluation
of a query. In other words, the current node is the first context node that the XPath
processor uses when it starts to execute the query. During evaluation of a query, the
current node does not change. If you pass a document to the XPath processor, the root
node is the current node. If you pass a node to the XPath processor, that node is the current
node.
Document Element
The document element is the element in a document that contains all other elements. The
document element is an immediate child of the root node. When you obtain the document
element of a document, you obtain all marked-up text in that document.
Stylus Studio User Guide
721
Filter
A filter in a query specifies a restriction on the set of nodes to be returned. For example,
the filter in the following query restricts the result set to book elements that contain at least
one excerpt element:
book[excerpt]
Location Step
An XPath expression consists of one or more location steps. A location step has the
following format:
[axis::]node_test[[filter] [filter]...]
Node Test
You apply a node test to a list of nodes. A node test returns nodes of a particular type or
nodes with a particular name. For example, a node test might return all comment nodes, or
all book elements.
Root Node
The root node is the root of the tree. It does not occur anywhere else in the tree. The
document element node for a document is a child of the root node. The root node also has
as children processing instructions and comment nodes representing processing
instructions and comments that occur in the prolog and after the end of the document
element.
722
This query is simply the name of the element you want to search for. If the context node
is any one of the book elements, this query returns one author element. If the context node
is any other node, this query returns the empty set.
This query searches the children of the root node for a bookstore element. Because the
name of the document element is bookstore, the query returns it. If the name of the
document element is not bookstore, this query returns an empty set.
The following query returns the entire document, starting with the root node. As you can
see, the entire query is just a forward slash:
/
723
Suppose the context node is the first book element in the document. The following query
returns a single last-name element because it starts its search in the current context:
.//last-name
This query searches the current context for book child elements that contain award
elements. If the bookstore element is the context node, this query returns the two award
elements that are in the document.
For the sample bookstore data, the following two queries are equivalent. Both return all
last-name elements in the document.
//last-name
//author//last-name
724
The first query returns all last-name elements in the sample document or in any XML
document. The second query returns all last-name elements that are descendants of
author elements. In the sample data, last-name elements are always descendants of author
elements, so this query returns all last-name elements in the document. But in another
XML document, there might be last-name elements that are not descendants of author
elements. In that case, the query would not return those last-name elements.
Tip: // is useful when the exact structure is unknown. If you know the structure of your
document, avoid the use of //. A query that contains // is slower than a query with an
explicit path.
Remember, if you specify the name of an element as a complete query (for example, foo),
you obtain only the foo elements that are children of the current context node. You do not
necessarily obtain all foo elements in the document.
You can also specify the dot notation (.) to indicate that you want the XPath processor to
manipulate the current context. For example:
//title [. = "History of Trenton"]
In this example, the XPath processor finds all title elements. The dot indicates the
context node. This causes the XPath processor to check each title in turn to determine
whether its string value is History of Trenton.
725
The double dot (..) at the beginning of the query instructs the XPath processor to select
the parent of the context node. This query returns the title elements that are children of
the first book element, which is the parent of the first author element. In the bookstore.xml
document, there is only one such title element.
Now suppose that the context node is still the first author element and you want to obtain
the style attribute for the book that contains this author. The following query does this:
../@style
The double dot notation need not appear at the beginning of a query. It can appear
anywhere in a query string, just like the dot notation.
726
Expression
Result
/a
/a/b
//a
//a/b
Result
a or ./a
a/b
a//b
.//a
Returns all a elements in the document tree branch that starts with
the context node
../a
Returns all a elements in the document tree branch that are children
of the parent node of the context node.
727
name matches
Supported Axes
The XPath processor supports all XPath axes:
child
descendant
parent
ancestor
following-sibling
preceding-sibling
following
preceding
attribute
namespace
self
descendant-or-self
ancestor-or-self
If the context node is the bookstore element, each of these queries return the book
elements in bookstore.xml. When you do not specify an axis, the child axis is assumed.
728
If the context node is the bookstore element, this query returns all first-name elements in
the document. If the context node is the first publication element, this query returns the
first-name element that is in the publication element.
If the first title element in bookstore.xml is the context node, this query returns the first
book element.
Note that dot dot (..) is equivalent to parent::node().
If the context node is the first title element in bookstore.xml, this query returns the first
book element.
729
bookstore.xml, this
If the context node is the third book element in bookstore.xml, this query returns the
second book element. If the context node is the first book element, this query returns the
empty set.
Attribute nodes
Namespace nodes
730
The following example selects the book elements that are following siblings of the context
node and that follow the context node in document order:
following::book
If the context node is the first book element, this query returns the last three book elements.
If the context node is the second book element, this query returns only the third and fourth
book elements.
Attribute nodes
Namespace nodes
The following example selects the book elements that are preceding siblings of the context
node and that precede the context node in document order:
preceding::book
If the third book element is the context node, this query returns the first two book elements.
If the first book element is the context node, this query returns the empty set.
731
If the context node is the second book element, this query returns a style attribute whose
value is textbook.
Context node
If the context node is the first-name element that is in the author element in the second
book element, this query returns just the context node. If the context node is the second
book element, this query returns the two first-name elements contained in the second book
element.
Note that // is equivalent to descendant-or-self::node(), while //name is equivalent to
descendant-or-self::node()/child::name.
732
If the context node is the award element in the first book element, this query returns the
first author element.
ancestor
preceding
self
following
descendant
preceding Axis
self Axis
following Axis
descendant Axis
733
Finding Substrings That Appear Before Strings You Specify on page 735
Finding Substrings That Appear After Strings You Specify on page 736
This query finds all name elements that contain only the text Lu. It would return elements
like these:
<name>Lu</name>
<name>
<firstname>Lu</firstname>
</name>
734
The XPath processor does not return the first name element because the comparison is
between "Lu" and "Lu Chen". The query does not return the second name element because
the XPath processor concatenates the two strings "Lu" and "Chen" before it makes the
evaluation. Consequently, the comparison is between "Lu" and "LuChen". Note that the
XPath processor does not insert a space between text nodes that it concatenates.
Case Sensitivity
Searches are case sensitive. A search for "Lu" does not return "lu".
The contains() function returns true if the first argument string contains the second
argument string, and otherwise returns false. For example, the following query returns all
books that have a title that contains the string "Trenton":
/bookstore/book[contains(title, "Trenton")]
When the first argument is a node list, the XPath processor tests only the string value of
the node in the node list that is first in document order. Any subsequent nodes are ignored.
The substring-before() function returns the substring of the first argument string that
precedes the first occurrence of the second argument string in the first argument string.
This function returns the empty string if the first argument string does not contain the
second argument string. For example, the following call returns "1999":
substring-before("1999/04/01","/")
735
The substring-after() function returns the substring of the first argument string that
follows the first occurrence of the second argument string in the first argument string. This
function returns the empty string if the first argument string does not contain the second
argument string. For example, the following call returns "04/01":
substring-after("1999/04/01","/")
The substring() function returns the substring of the first argument, starting at the
position specified in the second argument, with length specified in the third argument. For
example, the following returns "234":
substring("12345", 2, 3)
If you do not specify the third argument, the substring() function returns the substring
starting at the position specified in the second argument and continuing to the end of the
string. For example, the following call returns "2345":
substring("12345", 2)
More precisely, each character in the string is considered to have a numeric position. The
position of the first character is 1. The position of the second character is 2, and so on. The
returned substring contains those characters for which the position of the character is
greater than or equal to the rounded second argument and, if the third argument is
specified, less than the sum of the value of the second and third arguments. The
comparisons and addition used for the preceding follow the standard IEEE 754 rules. The
736
XPath processor rounds the second and third arguments as if by a call to the
function. For example:
substring("12345",
substring("12345",
substring("12345",
substring("12345",
substring("12345",
substring("12345",
round()
Manipulating Strings
After you obtain a string, you might want to manipulate it and use the result in the query.
This section describes functions that allow you to do this. It discusses the following
topics:
Concatenating Strings
To concatenate two or more strings, call the concat() function. The format is
string concat(string, string, {string}...)
The string-length() function returns the number of characters in the string. If you omit
the argument, it defaults to the string value of the context node.
737
Normalizing Strings
To strip leading and trailing white space from a string, call the normalize-space()
function. The format is
string normalize-space(string?)
The normalize-space() function removes leading and trailing white space. White space
consists of spaces, tabs, new lines, and returns.
If there are consecutive internal spaces, the normalize-space() function collapses the
internal spaces into one space. The normalize-space() function returns the string with the
extraneous white space removed. If you omit the argument, it defaults to the string value
of the context node.
The translate() function looks for characters in the first string that are also in the second
string. For each such character, the translate() function replaces the character in the first
string with a character from the third string. The replacement character is the character in
the third string that is in the same position as the character in the second string that
corresponds to the character being replaced. For example:
translate("bar", "abc", "ABC")
Execution of this function returns "AAA". Sometimes there is a character in the second
argument string with no character at a corresponding position in the third argument string.
This happens when the second argument string is longer than the third argument string.
In this case, the XPath processor removes occurrences of that character.
If a character occurs more than once in the second argument string, the first occurrence
determines the replacement character. If the third argument string is longer than the
second argument string, the XPath processor ignores the excess characters.
738
The string() function can convert any object to a string. If you omit the argument, it
defaults to a node set with the context node as the only member. The string value of an
element node is the concatenation of the string values of all text node descendants of the
element node in document order.
Node Sets
When the string() function converts a node set to a string, it returns the string value of
the node in the node set that is first in document order. If the node set is empty, the
string() function returns an empty string.
Numbers
The
Boolean
Values
string() function
The string() function converts the Boolean false value to the string "false", and the
Boolean true value to the string "true".
739
This function returns true if the first argument string starts with the second argument
string, and otherwise returns false.
Replace pathExpression with the path of the node or nodes that contain the text you want.
This can be a rooted path or a relative path. It need not be a single node. If you do not
explicitly specify the string() function, you must specify pathExpression in a context
where the XPath processor must treat it as a string, for example:
/bookstore/book[title = "Trenton Revisited"]
The XPath processor obtains the text contained in each title element and compares it
with "Trenton Revisited". The XPath processor returns books with the title Trenton
Revisited.
For additional information about the string() function, see Converting Objects to
Strings on page 739.
740
and
or
not
You can use parentheses to group collection specifications and operators for clarity or
where the normal precedence is inadequate to express an operation.
Case Sensitivity
Operators are case sensitive. Spaces are not significant. You can omit them or include
them for clarity.
Examples
The following query returns all authors who have at least one degree and one award:
author[degree and award]
The next query finds all authors who have at least one degree or award and at least one
publication:
author[(degree or award) and publication]
Following is a query that finds all authors who have at least one degree and no
publications:
author[degree and not(publication)]
741
Positive zero
Negative zero
742
The not() function returns true if its argument is false, and returns false if its argument
is true. For example, the following query finds all authors who have publications but no
degrees or awards:
author[not(degree or award) and publication]
true,
call the
true() function.
The format is
boolean true()
false,
call the
false()
boolean false()
The lang() function returns true or false depending on whether the language of the
context node as specified by the xml:lang attribute is the same as, or is a sublanguage of,
the language specified by the argument string. The language of the context node is
determined by the value of the xml:lang attribute on the context node or, if the context
node has no xml:lang attribute, by the value of the xml:lang attribute on the nearest
ancestor of the context node that has an xml:lang attribute.
If there is no such attribute, then lang() returns false. If there is such an attribute, lang()
returns true in the following situations:
The attribute value has a suffix starting with a dash (-) such that the attribute value is
equal to the argument string if you ignore the suffix.
Stylus Studio User Guide
743
<para xml:lang="en"/>
<div xml:lang="en"><para/></div>
<para xml:lang="EN"/>
<para xml:lang="en-us"/>
+ performs addition
- performs subtraction
XML allows hyphens (-) in names. Consequently, the subtraction operator ()
typically needs to be preceded by white space. For example, foo-bar evaluates to a
node set that contains the child elements named foo-bar. However, foo - bar evaluates
to the difference between the result of converting the string value of the first foo child
element to a number and the result of converting the string value of the first bar child
to a number.
* performs multiplication
5 mod 2 returns 1.
5 mod -2 returns 1.
The mod operator is the same as the % operator in Java and ECMAScript. But it does
not perform the same operation as the IEEE remainder operation, which returns the
remainder from a rounding division.
div performs floating-point division according to IEEE 754.
745
If you omit the argument, the value of the argument defaults to a node set with the context
node as its only member. Table 95 shows how the number() function converts its argument
to a number:
Table 95. number() Function Arguments and Converted Values
Argument
Converted Value
Boolean true
Boolean false
Node set
For each node in the argument node-set, the XPath processor converts the string value of
the node to a number. The sum() function returns the sum of these numbers.
floor()
number floor(number)
The floor() function returns the largest (closest to positive infinity) number that is not
greater than the argument and that is an integer. For example:
746
Comparing Values
floor(5.3) returns 5
floor(-5.3) returns -6
To obtain the smallest integer that is not less than a particular number, call the
function. The format is
ceiling()
number ceiling(number)
The ceiling() function returns the smallest (closest to negative infinity) number that is
not less than the argument and that is an integer. For example:
ceiling(5.3) returns 6
ceiling(-5.3) returns -5
To obtain the closest integer to a particular number, call the
is
number round(number)
The round() function returns the number that is closest to the argument and that is an
integer. If there are two such numbers, the function returns the one that is closest to
positive infinity. For example:
round(5.3) returns 5
round(5.6) returns 6
round(5.5) returns 6
Comparing Values
In queries, you can specify operators that compare values. Comparison operations return
Boolean values. If you want to obtain the nodes for which a comparison tests true, enclose
the comparison in a filter.
This section discusses the following topics:
Comparing Single Values With <=, <, >, and >= on page 751
747
Description
Equality
!=
Inequality
<
Less than
<=
>
Greater than
>=
You can specify single or double quotation marks (' or ") as string delimiters in
expressions. This makes it easier to construct and pass queries from within scripting
languages.
The XPath processor compares the value of each last-name element in the current context
with the value "foo". The result of each comparison is a Boolean value. The XPath
processor returns the last-name elements for which the comparison yields true.
As mentioned before in Filtering Results of Queries on page 713, the XPath processor
evaluates filters with respect to a context. For example, the expression book[author]
means for every book element that is found, determine whether it has an author child
element. Likewise, book[author = "Bob"] means for every book element that is found,
determine whether it contains an author child element whose value is "Bob".
748
Comparing Values
Comparisons are case sensitive. For example, "Bob" and "bob" are not considered to be
equal.
Remember that comparisons return Boolean values. For example:
/bookstore/book/author/last-name="Bob"
You might think that this query returns authors whose last name is "Bob". But this is not
the case. This query returns a single Boolean value. It tests each last-name element to
determine if its value is "Bob". As soon as the XPath processor finds a last-name element
that tests true, it returns true. If no nodes test true, this query returns false.
To obtain author elements whose last name is "Bob", enclose the comparison in a filter as
follows:
/bookstore/book/author[last-name="Bob"]
749
If at least one object to be compared is Boolean, the XPath processor converts the
other object to Boolean as if by applying the boolean() function.
If at least one object to be compared is a number, and neither is Boolean, the XPath
processor converts the nonnumber object to a number as if by applying the number()
function.
If the objects to be compared are neither Boolean nor numeric, the XPath processor
compares the string values of the objects as if by applying the string() function to each
object.
The = comparison returns true if and only if the objects are equal. The != comparison
returns true if and only if the objects are not equal. Numbers are compared for equality
according to IEEE 754. Two Boolean values are equal if either both are true or both are
false. Two strings are equal if and only if they both consist of the same sequence of
Universal Character Set (UCS) characters.
Note Use single or double quotes to specify string values being used with a comparison
operator.
750
Comparing Values
<
<=
>
>=
The XPath processor always evaluates these comparisons in terms of numbers. You
cannot use the less than and greater than operators to order strings. This is especially
important to remember when you compare a number with a string. For example, suppose
you want to evaluate the expression
a < "foo"
The return value is always false. This is because number("foo") returns NaN, and the
resulting comparison, shown below, is always false.
a < NaN
751
Examples of Comparisons
The following query finds all authors whose last name is Bob:
author[last-name = "Bob"]
The next query finds authors whose degrees are not from Harvard:
author/degree[@from != "Harvard"]
The following query returns prices that are greater than 20 dollars. This assumes that the
current context contains one or more price elements.
price [. > 20]
752
The next query finds the author elements (in the current context) that contain a first-name
element. The query returns the third such author element.
(author[first-name])[position()=3]
Tip: If you do not know the position of the node you want, a call to the position()
function might help you. See Determining the Position Number of a Node on page 753.
The return value of the position() function depends on the specified axis. For example,
suppose the axis is one of the reverse axes, such as preceding, ancestor, or precedingsibling. The position() function returns the nth one in reverse document order that falls
in the specified axis.
The next query finds the first two book children in the current context:
book[position() <= 2]
753
The XPath processor executes the position() function with respect to the parent node.
Consider the following data:
<x>
<y/>
<y/>
</x>
<x>
<y/>
<y/>
</x>
The following expression returns the first y element contained in each x element:
x/y[position() = 1]
For more information, see also Finding an Element with a Particular ID on page 757.
<x>
<z>
<z/>
</x>
<x>
<y>
<y/>
</x>
<x>
<y>
<y/>
</x>
The following query returns the first y element contained in each x element. It returns the
elements on lines 6 and 10. The XPath processor finds all x elements. For each x element,
the XPath processor then returns the first y element it finds.
x/y[1]
The next query returns the first y element that is contained in an x element that is in the
context node set. It returns the element on line 6. The XPath processor finds all y elements
inside x elements. The XPath processor then returns the first element in that set.
(x/y)[1]
754
The next query returns the empty set. The XPath processor finds the first x element. It then
searches that first x element for the first y. Because the first x element does not contain a
y element, this query returns the empty set.
x[1]/y[1]
For information about position(), see Determining the Position Number of a Node on
page 753. For information about last(), see Determining the Context Size on page 764.
You can also specify a range of nodes. For example, the next query returns the second,
third, and fourth author elements:
author [(position() >= 2) and ( position() <= 4)]
To obtain a range of nodes, m to n, relative to the last node, use the following format:
(m <= position()) and (position() <= n)
755
For example, the following query obtains the last five nodes in the current context:
author [(last() 4) <= position()) and (position() <= last())]
The next query finds the first, the third through the fifth, and the last author elements:
author [(position() = 1) or
(position() >= 3 and position() <= 5) or
(position() = last())]
The XPath processor removes duplicate values. For the previous query, if there are only
five elements in the collection, the query returns only one copy of the fifth element.
The next example finds all author elements in which the first degree is a Ph.D.:
author[degree[1] = "Ph.D."]
When the XPath processor evaluates this expression, it creates a collection of book
elements where the authors last name is Bob. The XPath processor then returns the first
node in this collection.
The following two expressions appear to also return the first book whose authors last
name is Bob, but they do not. Instead, these queries both return a book whose authors last
name is Bob only if that book is the first book in the document.
//book[author/first-name="Bob"][position()=1]
//book[author/first-name="Bob" and position() = 1]
756
id(object)
The id() function evaluates to a set. It ignores the context node set except to evaluate the
functions argument. The result set contains an element node that has an attribute of type
ID whose value is identical to the string the object argument evaluates to. The element
node can appear anywhere in the document that is being queried.
For example:
id("special")
Type is ID
Value is special
Details about working with IDs are in the following topics:
Unique IDs
An element node can have a unique ID. This is the value of the attribute that is declared
in the DTD as type ID. No two elements in a document can have the same unique ID. If
757
an XML processor reports two elements in a document as having the same unique ID
(which is possible only if the document is invalid), the second element is treated as not
having a unique ID.
If a document does not have a DTD, the id() function always returns an empty node list.
comment()
Comment nodes.
node()
processinginstruction("name")
text()
758
Node Test
attribute()
document-node()
element()
item()
For each p element in the current context, the following query returns its second text child
node:
p/text()[2]
Following is a query that finds the third comment child in each foo element anywhere in
the document:
//foo/comment()[3]
This query returns the comment at the beginning of the bookstore.xml file:
"This file represents a fragment of a book store inventory database."
759
Obtaining a Union
Specify the | operator to combine collection sets. For example, the following query
returns all last-name elements and all first-name elements in the current context:
first-name | last-name
The result set can contain zero or more of each element that the | operator applies to. For
example, using the previous query, it is possible for the query to contain only first-name
elements if no last-name elements are found. The following query finds all book elements
and magazine elements in the bookstore element:
/bookstore/book | /bookstore/magazine
The next query finds all books and all authors in the current context:
book | book/author
The next query returns the first names, last names, and degrees of authors of books or
magazines in the current context:
((book | magazine)/author/first-name) |
(book | magazine)/author/last-name |
(book | magazine)/author/degree) )
A union can appear only as the first step in a location path expression. Consequently, the
following is incorrect because there is a union specification that is not in the first step of
a location path expression.
(book | magazine)/author/(first-name | last-name | degree)
The following query finds all books for which the authors first name is Bob and all
magazines with prices less than 10 dollars:
/bookstore/book[author/first-name = "Bob"] | magazine[price < 10]
760
Wildcards
An asterisk ( * ) specifies a wildcard name for element names. If there are comments
before the third element in the preceding example, this query does not include them in the
count. See Filtering Results of Queries on page 713.
Note Remember, an asterisk that is not preceded by an at sign (@) never returns attributes. The
XPath processor does not include attributes in node counts. See Attributes and
Wildcards on page 713.
761
namespace-uri() function.
The format is
string namespace-uri(node-set?)
The namespace-uri() function returns the namespace URI of the expanded name of the
node in the node-set argument that is first in document order. If the node-set argument is
empty, the first node has no expanded name, or the namespace URI of the expanded name
is null, the XPath processor returns an empty string. If you omit the argument, it defaults
to a node set with the context node as its only member.
Call the
/bookstore/my:book/namespace-uri()
For any other type of node, the XPath processor always returns an empty string.
The local-name() function returns the local part of the expanded name of the node in the
that is first in document order. If the node-set argument is empty or
the first node has no expanded name, the function returns an empty string. If you omit the
argument, it defaults to a node set with the context node as its only member. For example,
the following query returns my:book nodes:
node-set argument
/bookstore/my:*[local-name()="book"]
762
The name() function returns a string that represents the expanded name of the node in the
node-set argument that is first in document order. The returned string represents the
expanded name with respect to the namespace declarations in effect on the node whose
expanded name is being represented.
Typically, this is the name in the XML source. This need not be the case if there are
namespace declarations in effect on the node that associate multiple prefixes with the
same namespace.
If the node-set argument is empty or the first node has no expanded name, the XPath
processor returns an empty string. If you omit the argument, it defaults to a node set with
the context node as its only member.
Except for element and attribute nodes, the string that the name() function returns is the
same as the string the local-name() function returns.
The next query finds all book elements with the prefix my. This query does not return
unqualified book elements; that is, book elements in the default namespace.
my:book
The following query finds all book elements with a my prefix that have an author
subelement:
my:book[author]
The following query finds all book elements with a my prefix that have an author
subelement with a my prefix:
my:book[my:author]
763
The next example returns the style attribute with a my prefix for book elements in the
current context:
book/@my:style
This function returns the URI of the unparsed entity with the specified name that is in the
same document as the context node. If there is no such entity, this function returns an
empty string.
The count() function returns the number of nodes in the specified set. For example, the
following query finds all authors who have more than ten publications:
//author[count(publications) > 10]
last()
function, described
last()
number last()
The last() function returns a number equal to the context size of the expression
evaluation context. Essentially, the last() function returns the position number of the last
node in document order for the current context. For example, the following query returns
764
all books if there are three or more of them. There are three book elements in the current
context. Consequently, this query returns three book elements.
/bookstore/book[last() >= 3]
Obtaining the Current Node for the Current XSLT Template on page 766
Using Variables
In a query that you specify in a stylesheet, you can refer to variables that you defined
elsewhere in the stylesheet. Use the following format to refer to a variable:
$variable_name
In a stylesheet, you can define variables with either of the following instructions:
xsl:version returns 1.0 as the version of XSLT that the Stylus Studio XSLT processor
implements.
765
The string you specify must identify one of the three properties and must be a qualified
name. This function returns an object that represents the value of the system property you
specify.
Specify a string that identifies the name of the function. The XPath processor returns true
if it implements that function.
The current() function returns a node set that contains only the current node for the
current template. The current() function is specified in the W3C XSLT
Recommendation.
766
For example, the following stylesheet causes the XSLT processor to pass the bookstore
node to the outer xsl:for-each instruction:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/XSL/Transform" version="1.0" >
<xsl:template match="/">
<xsl:for-each select="bookstore">
<xsl:for-each select=
"book[@style=current()/@specialty]">
...
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The bookstore node is the current node within the outer xsl:for-each instruction. Within
the inner xsl:for-each instruction, a book node is the current node.
The current() function in the inner expression returns the bookstore element because the
bookstore element is the current node for the inner xsl:for-each instruction. The result
of the query contains book elements if the value of their style attribute is the same as the
value of the specialty attribute of the bookstore element (novel).
Suppose the select attribute in the inner
instead of the current() function:
xsl:for-each instruction
<xsl:for-each select="book[@style=./@specialty]">
In a query, the dot specifies the context node. This query would return a book if the value
of its style attribute was the same as the value of its specialty attribute.
You can nest xsl:for-each instructions more than one level deep. In any given nested
xsl:for-each instruction, the current() function returns the current node for the closest
enclosing xsl:for-each instruction.
767
The first argument specifies the name of the key. The value of this argument must be a
qualified name. The second argument specifies the node or nodes to examine. When the
second argument is a node set, the result is the union of the results of applying the key()
function to the string value of each of the nodes in the set. When the second argument is
any other type, the XPath processor converts the argument to a string, as if by a call to the
string() function. The key() function returns a node set that contains the nodes in the
same document as the context node that have a value for the named key that is equal to
this string.
For example, the videos.xml document, which is in the examples directory of the Stylus
Studio installation directory, contains the following elements:
<result>
<actors>
<actor id="00000003">Jones, Tommy Lee</actor>
...
</actors>
<videos>
<video id="id1235AA0">
<title>The Fugitive</title>
...
<actorRef>00000003</actorRef>
<actorRef>00000006</actorRef>
...
</video>
...
</videos>
</result>
When you display information about a video in a Web browser, you want to display the
names of the actors. Because the actors are referenced only by an ID number, you create
a key table in your stylesheet:
<xsl:key
name="actors"
match="/result/actors/actor"
use="@id"/>
This indexes all actors by their ID. To process a video, your stylesheet specifies the
following:
<xsl:for-each select="actorRef">
<xsl:value-of select="key('actors', .)"/>
</xsl:for-each>
768
This instructs the XPath processor to look up the actor element in the actors key table by
using the actorRef element as a key.
Format
The format for the generate-id() function is as follows:
string generate-id(node-set?)
The generate-id() function returns a string that uniquely identifies the node in node-set
that is first in document order. This string starts with xln and ends with eight hexadecimal
digits. Syntactically, the string is an XML name.
If the node-set argument is empty, the generate-id() function returns an empty string. If
you omit the node-set argument, the generate-id() function generates a temporary ID
for the context node.
769
The XPath processor examines the first argument. If it is a single value (that is, it is not a
node set) the XPath processor converts it to a string, if it is not already a string. Separate
directory names and the file name with a forward slash (/). See the following format:
This string must be an absolute path. The XPath processor retrieves the specified
document. The new context node is the root node of this document. Suppose you invoke
the document() function and the requested document does not exist. If the invocation is in
a stylesheet, the XPath processor returns an empty node set. If the invocation is anywhere
else, the XPath processor returns an error message.
770
Now suppose you pass this query to the document() function as follows:
document(/books/bookstore)
771
Source
Returns
boolean()
XPath
ceiling()
XPath
comment()
XPath
concat()
XPath
contains()
XPath
count()
XPath
current()
XPath
document()
XSLT
element-available()
XSLT
false()
XPath
page 743.
772
Source
Returns
floor()
XPath
function-available()
XSLT
generate-id()
XSLT
id()
XPath
key()
XSLT
lang()
XPath
last()
XPath
local-name()
XPath
name()
XPath
773
774
Function
Source
Returns
namespace-uri()
XPath
node()
XPath
normalize-space()
XPath
not()
XPath
number()
XPath
position()
XPath
processinginstruction()
XPath
round()
XPath
starts-with()
XPath
string()
XPath
Source
Returns
string-length()
XPath
substring()
XPath
substring-before()
XPath
substring-after()
XPath
sum()
XPath
system-property()
XSLT
translate()
XPath
true()
XPath
unparsed-entity-uri()
XSLT
775
Axes
XPath provides the following axes:
ancestor
ancestor-or-self
attribute
child
descendant
descendant-or-self
following
following-sibling
namespace
parent
preceding
preceding-sibling
self
Node Tests
XPath provides the following node tests:
* selects all nodes of the specified name. For the attribute axis, attributes are
selected. For the namespace axis, namespace nodes are selected. For all other axes,
element nodes are selected.
776
Filters
A filter specifies a constraint on a node set with respect to an axis to produce a new node
set.
Location Steps
A location step has the following format:
AxisSpecifier::NodeTest[Filter][Filter]...
XPath Expression
An XPath expression has one of the following formats:
LocationStep[/LocationStep]...
FunctionCall()[Filter]/LocationStep[/LocationStep]...
(Expression)[Filter]/LocationStep[/LocationStep]...
A function call or an XPath expression in parentheses can appear only at the very
beginning of an XPath expression. An expression in parentheses always returns a node
set. Any function that appears at the beginning of an XPath location step expression must
return a node set.
Description
No axis is specified in a
location step.
777
Description
//
..
778
Example
Description
para
node_test
Evaluates all children of the context node and returns those that test
true for the particular node_test
*/para
para[1]
Description
para[last()]
/doc/chapter[5]/sect
Selects the second section of the fifth chapter of the doc child of
the context node
ion[2]
para[@type="warning"
]
para[@type="warning"
][5]
para[5][@type="warni
ng"]
Selects para children of the context node that have type attributes
with a value of warning
Selects the fifth para child of the context node that has a type
attribute with a value of warning
Selects the fifth para child of the context node if that child has a
type attribute with a value of warning
chapter[title]
Selects the chapter children of the context node that have one or
more title children
//para
chapter//para
//olist/item
.//para
..
@*
@name
../@name
779
780
Chapter 11
XQuery support is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite. Some features, like query plan, are
available only in Stylus Studio XML Enterprise Suite.
Stylus Studio provides many features for working with XML Query (XQuery), including
a graphical mapper that allows you to construct a query without writing any code, and
tools to help you run and debug XQuery.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the XQuery
Mapper video.
You can learn more about other video demonstrations of the XQuery Mapper here:
http://www.stylusstudio.com/learn_xquery.html#xquery_1.
This chapter covers the following topics:
Working with Zip Archive Format Files as Data Sources on page 862
781
What is XQuery?
XML Query (XQuery) is the World Wide Web Consortium (W3C) language for querying
XML. XQuery is a language developed by the W3C XML Query working group.
Example
The XQuery grammar allows you to define expressions like those shown in the following
sample XQuery, R-Q2.xquery:
<result>
{
for $i in doc("items.xml")/items/item_tuple
let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno]
where contains($i/description,"Bicycle")
order by $i/itemno
return
<item_tuple>
{$i/itemno}
{$i/description}
<high_bid>
{ max ( for $c in $b/bid return xs:decimal($c) ) }
</high_bid>
</item_tuple>
}
</result>
782
This and other XQuery examples are provided in the Stylus Studio examples\XQuery
directory.
What is an XQuery?
In Stylus Studio, an XQuery is a document with a .xquery extension. Stylus Studio
expects documents with this extension to contain a query expressed using the XML Query
language.
A schema pane, which displays the schema of the source documents you are using to
build your XQuery. You can hide the schema pane to view more of the XQuery code
by clicking the show/hide button at the base of the splitter, which allows you to vary
the relative width of the two panes.
Tip
You can drag schema objects directly to the editing pane. This allows you to quickly
create FLWOR and XPath expressions, for example, without writing any code or
introducing typographical errors to the source.
783
Stylus Studios Sense:X automatic completion feature is supported for XQuery Sense:X
simplifies editing and helps ensure well-formed XML for queries you compose manually.
You can define other XQuery editor settings on the Editor General and Editor Format
pages of the Options dialog box. (Click Tools > Options.)
You can preview the XQuery result by clicking the Preview Result button (
). Results
are displayed in the Preview window at the bottom of the XQuery editor, and, optionally,
in any external application that you specify.
784
Mapper Tab
The Mapper tab provides an interface that allows you to compose and view your XQuery
graphically.
Source document pane, in which you add one or more source documents.
Target structure pane, in which you specify the structure of the result you want the
XQuery to return.
Mapper canvas, on which you can define conditions, functions, and operations for
source document nodes to filter return values that are then mapped to the target node.
Text pane. The text pane allows you to view the XQuery code while using the mapper.
This is a great way to see how changes to the mapper affect the XQuery code, without
the need to switch to the XQuery Source tab. Of course, the XQuery Source tab is
available if you prefer working with the code using a full-page view. All views
Mapper tab, XQuery Source tab, and the text pane are synchronized.
785
As with the XQuery Source tab, you can preview XQuery results from the Mapper tab by
clicking the Preview Result button (
). Debugging, however, can be performed from
the XQuery Source tab only.
See Building an XQuery Using the Mapper to learn more about the features of the XQuery
editor Mapper tab.
Plan Tab
The Plan tab displays how the DataDirect XQuery processor will execute your XQuery
code and includes information about the type of SQL statements that are used to access
relational data, when XML streaming is being used, which temporary tables are being
created, when variables are being called, and so on.
One of the main benefits of using the query plan feature is that it can help you tune your
queries for the best performance possible. See Using DataDirect XQuery Execution
Plans on page 895 for more information.
786
in XQuery given its current definition. For example, imagine creating a FLWOR block
that is not mapped to a node in the target structure. The FLWOR (pronounced flower)
block appears on the Mapper tab, but Stylus Studio does not generate any code for it or
display it on the XQuery Source tab, and when you return to the Mapper tab you will see
that the FLWOR block has been removed.
787
An XQuery Primer
This XQuery primer was adapted from a whitepaper written by Dr. Michael Kay. You can
read the original document on the Stylus Studio Web site. This primer covers the
following topics:
788
An XQuery Primer
Hello, world!
Enter a simple equation (2+2) and click the Preview Result button (
result is:
). Predictably, the
Finally, try the XQuery function current-time() and click the Preview Result button
( ):
11:27:38Z
Your results, will vary based on several conditions. For example, the XQuery processor
you use to execute the XQuery will affect the precision of the time value (fractions of
seconds), and the time zone (here, shown as Z) is determined by how your system is
configured.
None of these is a very useful query on its own, but within a query language you need to
be able to perform little calculations and XQuery has this covered. Further, XQuery is
designed so that expressions can be fully nested that is, any expression can be used
within any other expression, provided that it delivers a value of the right type and this
means that expressions that are primarily intended for selecting data within a where clause
can also be used as free-standing queries in their own right.
789
the entire file from your Stylus Studio installation directory, your doc() might look like
this:
doc('file:///c:/Program%20Files/Stylus%20Studio%20X14%20XML%20Professional
%20Suite/examples/VideoCenter/videos.xml')
To fetch this document from the Stylus Studio Web site, you would need a doc() like this:
doc('http://www.stylusstudio.com/examples/videos.xml')
(The latter doc() function will work only if you are online; and if you are behind a
corporate firewall you might have to modify your Java configuration to make it work.)
Handling URLs
URLs like those used in the previous example can be a bit unwieldy, but there are some
shortcuts you can use.
In Stylus Studio, you can specify the source document as the Main Input on the
General tab of the Scenario Properties dialog box. Once you browse to the
appropriate file and select it, you can refer to it in your XQuery code as simply .
(dot).
If you are working directly with a command line processor such as Saxon, you can
copy the file locally (c:\xquery\videos.xml, for example) and work with it from that
location. Once you have done this, you can use the command line option -s
c:\xquery\videos.xml and again be able to refer to the input document in your
XQuery code as . (dot).
790
An XQuery Primer
id="00000015">Anderson, Jeff</actor>
id="00000030">Bishop, Kevin</actor>
id="0000000f">Bonet, Lisa</actor>
id="00000024">Bowz, Eddie</actor>
id="0000002d">Curry, Tim</actor>
id="00000033">Dullea, Keir</actor>
id="00000042">Fisher, Carrie</actor>
id="00000006">Ford, Harrison</actor>
id="00000045">Foster, Jodie</actor>
That was our first real query. If you are familiar with XPath, you might recognize that
all the queries so far have been valid XPath expressions. We have used a couple of
functions current-time() and doc() that might be unfamiliar because they are new
in XPath 2.0, which is still only a draft; but the syntax of all the queries so far is plain
XPath syntax. In fact, the XQuery language is designed so that every valid XPath
expression is also a valid XQuery query.
This means we can write more complex XPath expressions like this one:
.//actors/actor[ends-with(., 'Lisa')]
Different systems might display this output in different ways. Technically, the result of
this query is a sequence of two element nodes in a tree representation of the source XML
document, and there are many ways a system might choose to display such a sequence on
the screen. Stylus Studio gives you the choice of a text view, like the one shown above,
and a tree view: you use the buttons next to the Preview window to switch from one to the
other. Here is what the tree view looks like:
This example used another function ends-with() that's new in XPath 2.0. We are
calling it inside a predicate (the expression between the square brackets), which defines a
condition that nodes must satisfy in order to be selected. This XPath expression has two
parts: a path .//actors/actor that indicates which elements we are interested in, and a
791
predicate [ends-with(., Lisa)] that indicates a test that the nodes must satisfy. The
predicate is evaluated once for each selected element; within the predicate, the expression
. (dot) refers to the node that the predicate is testing, that is, the selected actor.
The / in the path informally means go down one level, while the // means go
down any number of levels. If the path starts with ./ or .// you can leave out the
initial .. (This assumes that the selection starts from the top of the tree, which is always
the case in our examples.) You can also use constructs like /.. to go up one level, and
/@id to select an attribute. Again, this is all familiar if you already know XPath.
XPath is capable of doing some pretty powerful selections, and before we move on to
XQuery proper, let us look at a more complex example. Suppose we want to find the titles
of all the videos featuring an actor whose first name is Lisa. If we look at the videos.xml
file, we see that each video in the file is represented by a video element like this one:
<video id="647599251">
<studio></studio>
<director>Francesco Rosi</director>
<actorRef>916503211</actorRef>
<actorRef>916503212</actorRef>
<title>Carmen</title>
<dvd>18</dvd>
<laserdisk></laserdisk>
<laserdisk_stock></laserdisk_stock>
<genre>musical</genre>
<rating>PG</rating>
<runtime>125</runtime>
<user_rating>4</user_rating>
<summary>A fine screen adaptation of Bizet's popular opera.</summary>
<details>Placido Domingo does it again, this time in Bizet's popular opera.</details>
<vhs>15</vhs>
<beta_stock></beta_stock>
<year>1984</year>
<vhs_stock>88</vhs_stock>
<dvd_stock>22</dvd_stock>
<beta></beta>
</video>
The query required to provide the results we desire is written like this:
//video[actorRef=//actors/actor[ends-with(., 'Lisa')]/@id]/title
Again, this is pure XPath (and therefore a valid XQuery). You can read it from left-to-right
as:
792
An XQuery Primer
Choose those that have an actorRef element whose value is equal to one of the values
of the following:
When run against our source document, the result of this XQuery is:
<title>Enemy of the State</title>
<title>Clerks</title>
Many people find that at this level of complexity, XPath syntax gets rather mind-boggling.
In fact, this example just about stretches XPath to its limits. For this kind of query, and for
anything more complicated, XQuery syntax comes into its own. But it is worth
remembering that there are many simple things you can do with XPath alone, and that
every valid XPath expression is also valid in XQuery.
793
See Using the XPath Query Editor on page 694 to learn more about using this tool.
794
An XQuery Primer
where, order by, return. Here is the last example (all videos with an actor named Lisa,
rewritten this time as a FLWOR expression.
let $doc := .
for $v in $doc//video,
$a in $doc//actors/actor
where ends-with($a, 'Lisa')
and $v/actorRef = $a/@id
return $v/title
The let clause simply declares a variable. We included this here because when we
deploy the query we might want to set this variable differently; for example, we might
want to initialize it to doc(videos.xml), or to the result of some complex query that
locates the document in a database.
The for clause defines two range variables: one processes all the videos in turn, the
other processes all the actors in turn. Taken together, the FLWOR expression is
processing all possible pairs of videos and actors.
The where clause then selects those pairs that we are actually interested in. We are
only interested if the actor appears in that video, and we are only interested if the
actors name ends in Lisa.
Finally the return clause tells the system what information we want to get back. In this
case we want the title of the video.
If you have been following very closely, you might have noticed one little XPath trick that
we retained in this query: most videos will feature more than one actor (though this
particular database does not attempt to catalog the bit-part players). The expression
$v/actorRef therefore selects several elements. The rules for the = operator in XPath (and
therefore also in XQuery) are that it compares everything on the left with everything on
the right and returns true if there is at least one match. In effect, it is doing an implicit join.
If you want to avoid exploiting this feature, and you want to write your query in a more
classically relational form, you could express it as follows:
let $doc := .
for $v in $doc//video,
$va in $v/actorRef,
$a in $doc//actors/actor
where ends-with($a, 'Lisa')
and $va eq $a/@id
return $v/title
795
This time we used a different equality operator, eq, which follows more conventional rules
than = does: it strictly compares one value on the left with one value on the right. (But like
comparisons in SQL, it has special rules to handle the case where one of the values is
absent.)
What about the O in FLWOR? That is there so you can get the results in sorted order.
Suppose you want the videos in order of their release date. Here's the revised query:
let $doc := .
for $v in $doc//video,
$a in $doc//actors/actor
where ends-with($a, 'Lisa')
and $v/actorRef = $a/@id
order by $v/year
return $v/title
If you are wondering why FLWOR is not really a LFWOR expression: the for and let
clauses can appear in any order, and you can have any number of each. To learn more
about the FLWOR expression, see Understanding FLWOR Expressions on page 798.
796
An XQuery Primer
XQuery allows the structure of the result document to be defined using an XML-like
notation. Here is an example that fleshes out our previous query with some XML markup:
declare variable $firstName as xs:string external;
<videos featuring="{$firstName}">
{
let $doc := .
for $v in $doc//video,
$a in $doc//actors/actor
where ends-with($a, $firstName)
and $v/actorRef = $a/@id
order by $v/year
return
<video year="{$v/year}">
{$v/title}
</video>
}
</videos>
We have also changed the query so that the actor's first name is now an externally defined
parameter. This makes the query reusable. The way parameters are supplied varies from
one XQuery processor to another. In Stylus Studio, select XQuery > Scenario Properties;
click the Parameter Values tab, and Stylus Studio provides an area to specify values for
any variables defined in the XQuery.
Enter Lisa, in quotes (Stylus Studio expects an expression, so if the quotes are omitted,
this value would be taken as a reference to an element named <Lisa>).
If instead you are running Saxon from the command line, you can enter:
java net.sf.saxon.Query sample.xquery firstName=Lisa
As you might recall from our previous XQuery, this version of the XQuery is not
especially well-designed as it returns videos featuring different actresses named Lisa.
Take some time and modify the XQuery to see if you can improve it.
797
798
And if you know XPath, you might be wondering why our XQuery cannot be written as
this:
$doc//video[year=1999]/title
Well, you can. This XPath expression is completely equivalent to the FLWOR expression
above, and furthermore, it is a legal XQuery query. In fact, every legal XPath expression
is also legal in XQuery. Thus the first query in this section can be written as:
$doc//video
Which style you prefer seems to depend on where you are coming from: if you have been
using XML for years, especially XML with a deep hierarchy as found in narrative
documents, then you will probably be comfortable with path expressions. But if you are
more used to thinking of your data as representing a table, then the FLWOR style might
suit you better.
799
As you will see, FLWOR expressions are a lot more powerful than path expressions when
it comes to doing joins. But for simple queries, the capabilities overlap and you have a
choice. Although it might be true that in SQL every query is a SELECT statement, it is
not so that in XQuery every query has to be a FLWOR expression.
F is for For
The behavior of the for clause is fairly intuitive: it iterates over an input sequence and
calculates some value for each item in that sequence, returning a sequence obtained by
concatenating the results of these calculations. In simple cases there is one output item for
every input item. So, this FLWOR expression:
for $i in (1 to 10)
return $i * $i
returns the sequence (1, 4, 9, 16, 25, 36, 49, 64, 81, 100). In this example, the input items
are simple numbers, and the output items are also simple numbers. Numbers are an
example of what XQuery calls atomic values; other examples are strings, dates, booleans,
and URIs. But the XQuery data model allows sequences to contain XML nodes as well as
atomic values, and the for expression can work on either.
Here is an example that takes nodes as input, and produces numbers as output. It counts
the number of actors listed for each video in a data file:
for $v in //video
return count($v/actorRef)
You can run this in Stylus Studio or in Saxon, using the example videos.xml file as input.
(Tips on setting up these tools are described in the previous section, An XQuery Primer.)
Here's the output from Stylus Studio:
The Preview window shows the result: a rather mundane sequence of numbers (2, 4, 3, 3,
3...).
800
This gives us a good opportunity to point out that a FLWOR expression is just an
expression, and you can use it anywhere an expression is allowed: it doesn't have to be at
the top level of the query. There is a function, avg(), to compute the average of a sequence
of numbers, and we can use it here to find the average number of actors listed for each of
the movies in our data file:
avg(
for $v in //video
return count($v/actorRef)
)
The answer is 2.2941176 and a bit the number of decimal places shown will depend on
the XQuery processor that you use. If you are only interested in the answer to two decimal
places, try:
round-half-to-even(
avg(
for $v in //video
return count($v/actorRef)
),
2)
which gives a more manageable answer of 2.29. (The strange name round-half-to-even
is there to describe how this function does rounding: a value such as 2.145 is rounded to
the nearest even number, in this case 2.14.) This is all designed to demonstrate that
XQuery is a functional language, in which you can calculate a value by passing the result
of one expression or function into another expression or function. Any expression can be
nested inside any other, and the FLWOR expression is no exception.
If you are coming from SQL, your instinct was probably to try and do the averaging and
rounding in the return clause. But the XQuery way is actually much more logical. The
return clause calculates one value for each item in the input sequence, whereas the avg()
function applies to the result of the FLWOR expression as a whole.
As with some of the examples in An XQuery Primer, XPath 2.0 allows you to write this
example using path expressions alone if you prefer:
round-half-to-even(avg(//video/count(actorRef)), 2)
We have seen a for expression that produces a sequence of numbers from another
sequence of numbers, and we have seen one that produces a sequence of numbers from a
801
sequence of selected nodes. We can also turn numbers into nodes: the following query
selects the first five videos.
for $i in 1 to 5 return (//video)[$i]
And we can get from one sequence of nodes to another sequence of nodes. This example
shows all the actors that appear in any video:
for $actorId in //video/actorRef
return //actors/actor[@id=$actorId]
In fact, this last example probably represents the most common kind of for expression
encountered, but we introduced it last to avoid leaving you with the impression that it is
the only kind there is.
Once again, you could write this example as an XPath expression:
//actors/actor[@id=//video/actorRef]
However, this time the two expressions are not precisely equivalent. Try them both in
Stylus Studio: the FLWOR expression produces a list containing 38 actors, while the list
produced by the path expression contains only 36. The reason is that path expressions
eliminate duplicates, and FLWOR expressions do not. Two actors are listed twice because
they appear in more than one video.
The FLWOR expression and the / operator in fact perform quite similar roles: they
apply a calculation to every item in a sequence and return the sequence containing the
results of these calculations. There are three main differences between the constructs:
The for expression defines a variable $v that is used in the return clause to refer to
each successive item in the input sequence; a path expression instead uses the notion
of a context item, which you can refer to as . In this example, //video is short for
./root()//video, so the reference to the context item is implicit.
With the / operator, the expression on the left must always select nodes rather than
atomic values. In the earlier example //video/count(actorRef), the expression on
the right returned a number that's a new feature in XPath 2.0 but the left-hand
expression must still return nodes.
When a path expression selects nodes, they are always returned in document order,
with duplicates removed. For example, the expression $doc//section//para will
return each qualifying <para> element exactly once, even if it appears in several
nested <section> elements. If you used the nearest-equivalent FLWOR expression,
for $s in $doc//section return $s//para, then a <para> that appears in several
802
nested sections would appear several times in the output, and the order of <para>
elements in the output will not necessarily be the same as their order in the original
document.
The for clause really comes into its own when you have more than one of them in a
FLWOR expression. We will explore that a little later, when we start looking at joins. But
first, let's take a look at the other clauses: starting with let.
L is for Let
The XQuery let clause simply declares a variable and gives it a value:
let $maxCredit := 3000
let $overdrawnCustomers := //customer[overdraft > $maxCredit]
return count($overdrawnCustomers)
Hopefully the meaning of that is fairly intuitive. In fact, in this example you can simply
replace each variable reference by the expression that provides the expression's value.
This means that the result is the same as this:
count(//customer[overdraft > 3000])
In a for clause, the variable is bound to each item in the sequence in turn. In a let clause,
the variable only takes one value. This can be a single item or a sequence (there is no real
distinction in XQuery an item is just a sequence of length one). And of course the
sequence can contain nodes, or atomic values, or (if you really want) a mixture of the two.
In most cases, variables are used purely for convenience, to simplify the expressions and
make the code more readable. If you need to use the same expression more than once, then
declaring a variable is also a good hint to the XQuery processor to only do the evaluation
once.
In a FLWOR expression, you can have any number of for clauses, and any number of let
clauses, and they can be in any order. For example (returning to the videos.xml data
again), you can do this:
for $genre in //genre/choice
let $genreVideos := //video[genre = $genre]
let $genreActorRefs := $genreVideos/actorRef
for $actor in //actor[@id = $genreActorRefs]
return concat($genre, ": ", $actor)
803
For each choice of genre, lets call the set of videos in that genre $genreVideos. Now
lets call the set of references to all the actors in all those videos $genreActorRefs.
For each actor whose ID is equal to one of the references in $genreActorRefs, output
a string formed by concatenating the name of the genre and the name of the actor,
separated by a colon.
Here is the result in Stylus Studio:
As a quick aside, the Stylus Studio XQuery Mapper allows you to visually map from one
or more XML input documents to any target output format. In a nutshell click on the
Mapper tab on the bottom of the XQuery Editor. Next, click Add Source Document and
add your source document(s). Our last XQuery would look like this in the XQuery
Mapper:
The FLWOR block is graphically represented as a function block with three input ports
going into it on the left (For, Where, Order By), a flow control port on the top, and an
output port on the right. As you draw your XML mappings, Stylus Studio writes the
XQuery code; similarly, you can edit the XQuery code manually and Stylus Studio which
will update the graphical model both views of the XQuery are kept synchronized. See
Building an XQuery Using the Mapper for more information on the Mapper module.
One important thing to note about variables in XQuery (you can skip this if you already
know XSLT, because the same rule applies there): variables cannot be updated. This
means you cannot write something like let $x := $x+1. This rule might seem very
strange if you are expecting XQuery to behave in the same way as procedural languages
such as JavaScript. But XQuery is not that kind of language, it is a declarative language
and works at a higher level. There are no rules about the order in which different
expressions are executed (which means that the little yellow triangle that shows the
current execution point in the Stylus Studio XQuery debugger and XSLT debugger can
sometimes behave in surprising ways), and this means that constructs whose result would
depend on order of execution (like variable assignment) are banned. This constraint is
essential to give optimizers the chance to find execution strategies that can search vast
databases in fractions of a second. Most XSLT users (like SQL users before them) have
found that this declarative style of programming grows on you. You start to realize that it
enables you to code at a higher level: you tell the system what results you want, rather
than telling it how to go about constructing those results.
804
You might ask yourself at this point, Isnt a variable being updated when we write
something like the following?
for $v in //video
let $x := xs:int($v/runtime) * xdt:dayTimeDuration("PT1M")
return concat($v/title, ": ",
hours-from-duration($x), " hour(s) ",
minutes-from-duration($x), " minutes")
(This query shows the running time of each video. It first converts the stored value from
a string to an integer, then multiplies it by one minute (PT1M) to get the running time as a
duration, so that it can extract the hours and minutes components of the duration. Try it.)
Here the variable $x has a different value each time around the XQuery for loop. This feels
a bit like an update. Technically though, each time round the for loop you are creating a
new variable with a new value, rather than assigning a new value to the old variable. What
you cannot do is to accumulate a value as you go around the loop. Try doing this to see
what happens:
let $totalDuration := 0
for $v in //video
let $totalDuration := $totalDuration + $v/runtime
return $totalDuration
The result is not a single number, but a sequence of numbers, one for each video. This
example is actually declaring two separate variables that happen to have the same name.
You are allowed to use the same variable name more than once, but this is probably not a
good idea, because it will only get your readers confused. You can see more clearly what
this query does if we rename one of the variables.
let $zero := 0
for $v in //video
let $totalDuration := $zero + $v/runtime
return $totalDuration
Hopefully it is now clear why this returns a sequence of numbers rather than a single total.
The correct way to get the total duration is to use the sum function:
sum(//video/runtime).
805
W is for Where
The XQuery where clause in a FLWOR expression performs a very similar function to the
WHERE clause in a SQL select statement: it specifies a condition to filter the items we are
interested in. The where clause in a FLWOR expression is optional, but if it appears it must
only appear once, after all the for and let clauses. Here is an example that restates one
of our earlier queries, but this time using a where clause:
for $genre in //genre/choice
for $video in //video
for $actorRefs in $video/actorRef
for $actor in //actor
where $video/genre = $genre
and $actor/@id = $actorRefs
return concat($genre, ": ", $actor)
This style of coding is something that SQL users tend to be very comfortable with: first
define all the tables you are interested in, then define a WHERE expression to define all the
restriction conditions that select subsets of the rows in each table, and join conditions that
show how the various tables are related.
Although many users seem to find that this style comes naturally, an alternative is to do
the restriction in a predicate attached to one of the for clauses, like this:
for $genre in //genre/choice
for $video in //video[genre = $genre]
for $actorRefs in $video/actorRef
for $actor in //actor[@id = $actorRefs]
return concat($genre, ": ", $actor)
Perhaps there is a balance between the two; you will have to find the style that suits you
best. With some XQuery processors one style or the other might perform better (and with
Stylus Studio, you can easily create multiple XQuery scenarios that execute the same code
but use different XQuery processors), but a decent optimizer is going to treat the two
forms as equivalent.
Do remember that in a predicate, you select the item that you are testing relative to the
context node, while in the where clause, you select it using a variable name. A bare name
such as genre is actually selecting ./child::genre that is, it is selecting a child of the
context node, which in this case is a <video> element. It is very common to use such
expressions in predicates, and it is very uncommon to use them (except by mistake!) in
the where clause. If you use a schema-aware processor like Saxon, then you might get an
error message when you make this mistake; in other cases, it is likely that the condition
806
will not select anything. The where condition will therefore evaluate to false, and you will
have to puzzle out why your result set is empty.
O is for Order By
If there is no order by clause in a FLWOR expression, then the order of the results is as
if the for clauses defined a set of nested loops. This does not mean they actually have to
be evaluated as nested loops, but the result has to be the same as if they were. That is an
important difference from SQL, where the result order in the absence of any explicit
sorting is undefined. In fact, XQuery defines an alternative mode of execution, unordered
mode, which is similar to the SQL rules. You can select this in the query prolog, and the
processor might even make it the default (this is most likely to happen with products that
use XQuery to search a relational database). Some products (Stylus Studio and Saxon
among them) give you exactly the same result whether or not you specify unordered mode
since the XQuery specification says that in unordered mode anything goes, that is
perfectly acceptable.
Often however you want the query results in sorted order, and this can be achieved using
the order by clause. Let's sort our videos in ascending order of year, and within that in
decreasing order of the user rating:
for $x in //video
order by $x/year ascending, number($x/user-rating) descending
return $x/title
Note that we have not actually included the sort keys in the data that we are returning
(which makes it a little difficult to verify that it is working properly; but it is something
you might well want to do in practice). We have explicitly converted the user-rating to a
number here to use numeric sorting: this makes sure that 10 is considered a higher rating
than 2. This is not necessary if the query is schema-aware, because the XQuery processor
then knows that user-rating is a numeric field.
Ordering gets a little complicated when there is more than one for clause in the FLWOR
expression. Consider this example:
for $v in //video
for $a in //actor
where $v/actorRef = $a/@id
order by $a, $v/year
return concat($a, ":", $v/title)
To understand this we have to stop thinking about the two for clauses as representing a
nested loop. We cannot compute all the result values and then sort them, because the result
Stylus Studio User Guide
807
does not contain all the data used for sorting (it orders the videos for each actor by year,
but only shows their titles). In this case we could imagine implementing the order
specification by rearranging the for clauses and doing a nested loop evaluation with a
different order of nesting; but that doesn't work in the general case. For example, it
wouldn't work if the order by clause changed to:
order by substring-after($a, ","),
$v/year,
substring-before($a, ",")
to sort first on the surname, then on the year, then on the first name (admittedly,
nonsensical coding, but we show it only to illustrate that it is allowed).
The XQuery specification introduces a concept of tuples, borrowed from the relational
model, and describes how the sort works in terms of creating a sequence of tuples
containing one value for each of the variables, and then sorting these notional tuples.
R is for Return
Every XQuery FLWOR expression has a return clause, and it always comes last. It
defines the items that are included in the result. What more can one say about it?
Usually the XQuery return clause generates a single item each time it is evaluated. In
general, though, it can produce a sequence. For example, you can do this:
for $v in //video[genre="comedy"]
return //actor[@id = $v/actorRef]
which selects all the actors for each comedy video. However, the result is a little
unsatisfactory, because we cannot tell which actors belong to which video. It is much
more common here to construct an element wrapper around each result:
for $v in //video[genre="comedy"]
return
<actors video="{$v/title}">
{//actor[@id = $v/actorRef]}
</actors>
We have not discussed XQuery element and attribute constructors until now. But in
practice, a FLWOR expression without element constructors can only produce flat lists of
values or nodes, and that is not usually enough. We usually want to produce an XML
document as the output of the query, and XML documents are not flat.
808
This means that very often, instead of doing purely relational joins that generate a flat
output, we want to construct hierarchic output using a number of nested FLWOR
expressions. Here is an example that (like the previous query) lists the videos for each
actor, but with more structure this time:
for $v in //video[genre="comedy"]
return
<actors video="{$v/title}">
{for $a in //actor[@id = $v/actorRef]
return
<actor>
<firstname>{substring-after($a, ",")}</firstname>
<lastname>{substring-before($a, ",")}</lastname>
</actor>
}
</actors>
Here we really do have two nested XQuery loops. The two queries below are superficially
similar, and in fact they return the same result:
for $i in 1 to 5
for $j in ("a", "b", "c")
return concat($j, $i)
and:
for $i in 1 to 5
return
for $j in ("a", "b", "c")
return concat($j, $i)
and:
for $i in 1 to 5
return
for $j in ("a", "b", "c")
order by $j, $i
return concat($j, $i )
809
The difference now becomes apparent. In the first case the result sequence is a1, a2, a3,
b1, b2, b3,. In the second case it remains a1, b1, c1, a2, b2, c2. The reason is that the
first query is a single FLWOR expression (one return clause), and the order by clause
affects the whole expression. The second query consists of two nested loops, and the
order by clause can only influence the inner loop.
So, the return clause might seem like the least significant part of the FLWOR, but a
misplaced return can make a big difference in the result. Consider always aligning the F,
L, O, W, and R clauses of a single FLWOR expression underneath each other, and
indenting any nested expressions, so that you can see what is going on. You can do this
easily with the Stylus Studio XQuery Editor.
Declaring types can be useful as a way of asserting what you believe the results of the
expressions are, and getting an error message (rather than garbage output) if you have
made a mistake. It helps other people coming along later to understand what the code is
doing, and to avoid introducing errors when they make changes.
Unlike types declared in other contexts such as function signatures (and unlike variables
in XSLT 2.0), the types you declare must be exactly right. The system does not make any
attempt to convert the actual value of the expression to the type you declare for example
it will not convert an integer to a double, or extract the string value of an attribute node.
810
If you declare the type as string but the expression delivers an attribute node, that is a fatal
error.
This selects all the even-numbered videos useful if you are arranging the data in a table.
You can use $pos anywhere where you might use the primary variable $v. Its value ranges
from 1 to the number of items in the //video sequence. If there are no order by clauses,
then the position variables in each for clause follow a nested-loop model as you would
expect. If there is an order by clause, the position values represent the position of the
items before sorting (which is different from the rule in XSLT).
There are various keywords in the order by clause that give you finer control over how
the sorting takes place. The most important is the collation: unfortunately, though, the
way collations work is likely to be very product-dependent. The basic idea is that if you
are sorting the index at the back of a book, or the names in a phone directory, then you
need to apply rather more intelligent rules than simply sorting on the numeric Unicode
code value of each character. Upper-case and lower-case variants of letters may need to
be treated the same way, and accents on letters have some quite subtle rules in many
languages. The working group defining XQuery settled on the simple rule that every
collating sequence you might want has a name (specifically, a URI rather like a
namespace URI), and it is up to each vendor to decide what collations to provide and how
to name them.
Other things you can say in the order specification include defining whether empty values
of the sort key (XQuery's equivalent of null values in SQL) should go at the start or end
of the sequence, and whether the sort should be stable, in the sense that items with equal
sort key values preserve their original order.
811
Multiple Assignments
One simple syntax note. Instead of writing
for $i in ("a", "b", "c")
for $j in 1 to 5
return concat($i, $j)
The meaning of both is the same. This same technique applies to let statements as well.
Grouping
If you are used to SQL, then you might have been wondering what the equivalent to its
DISTINCT and GROUP BY keywords is in XQuery FLOWR expressions. Well, SQL does not
have one.
You can, however, get a fair amount of mileage from the distinct-values() function.
Here is a query that groups videos according to who directed them:
<movies>
{for $d in distinct-values(//director) return
<director name="{$d}">
{ for $v in //video[director = $d] return
<title>{$v/title}</title>
}
</director>
}
</movies>
This is not an ideal solution: apart from anything else, it depends heavily on the ability of
the query processor to optimize the two nested loops to give good performance. But for
the time being, this is all there is. This is an area where vendors are very likely to offer
extensions to the language as defined by W3C.
Grouping was a notoriously weak point of XSLT 1.0, and the problem has been addressed
with considerable success in the 2.0 version of the language. XQuery will likely follow
suit.
812
Process Overview
Data Sources
Exporting Mappings
FLWOR Blocks
Function Blocks
IF Blocks
Condition Blocks
Predicate Blocks
Process Overview
The process of using the XQuery mapper to build a new XQuery consists of the following
steps:
1.
Create a new XQuery file in Stylus Studio (File > New > XQuery File).
2.
3.
Add one or more data sources (documents or relational database tables, for example).
4.
813
Map data source nodes to target structure nodes. As part of this step, you can
optionally define function, FLWOR (For each, Let, Where, Order by, Return), If, and
condition blocks to perform actions on source document nodes and map the return
value to the target structure node.
Stylus Studio uses the information expressed on the Mapper tab to compose an XQuery
that returns as its result an XML document that conforms to the structure represented by
the target structure you specify.
Each of these steps is described in greater detail in the following sections.
Data Sources
The role of a data source is to provide Stylus Studio with a structure that it can use to
compose the XQuery based on how you map individual source objects (XML elements
and attributes, or table rows, for example) to nodes in the target structure. Stylus Studio
infers the structure from the data source you specify and displays this structure on the Add
Source Document pane of the Mapper tab.
In Stylus Studio, a data source can be one or more of the following:
XML document
814
Zip files
815
Itself. That is, the document represented by structure displayed on the Mapper tab and
the XML instance are one in the same. In this situation, Stylus Studio generates the
doc() function in the XQuery code. For example:
The XML document specified in the optional XQuery scenario. Only one source
document can be associated with the XQuery scenario. In this situation, Stylus Studio
does not generate the doc() function in the XQuery code. For example:
for $book in /books/book
The doc() function is not necessary because Stylus Studio uses the XQuery input
document specified in the Scenario Properties dialog box.
By default, Stylus Studio uses the first XML document you add to the XQuery mapper
as the source XML for the XQuery scenario, as shown here:
The document specified in the Source XML URL field on the Scenario Properties
dialog box is the document used to preview XQuery results. You can select this
association for another XML document if you choose, but only one source document
may have this association.
Note
816
Some other XML instance. A XSD or DTD document used as an XQuery source
document must always be associated with an XML instance. In this situation, Stylus
Studio generates the doc() function in the XQuery code.
Source icons
Stylus Studio uses different icons to indicate how a source is associated with the other
sources used to compose the XQuery.
Table 103. Source Document Icons
Icon
Meaning
The source document is associated with itself. This is the default for
most XML documents (and XML documents only).
The source document is associated with the XML document
specified in the XQuery scenario. This is the case with the first XML
document you add to XQuery mapper, but you can change this
association manually if you choose. See How to Change a Source
Document Association.
The source document is associated with a separate XML document
instance. XSD and DTD source documents are always associated
with an XML instance.
The source is a relational database table. A relational data source can
only be associated with itself.
2.
Click the Add Source Document button at the top left of the Mapper tab.
The Open dialog box appears.
3.
Select the document you want to use as the source document for building the XQuery.
817
Click Open.
If you selected an XML document in Step 3, the document appears in the source
document pane of the Mapper tab. Go to Step 5.
If you selected an XSD or DTD document, Stylus Studio displays the Choose Root
Element dialog box.
You use this dialog box to associate the XSD or DTD with an XML instance.
The Associate With field appears only when you add a second document to the
XQuery mapper source and that document is an XSD or DTD. You use it to specify
the XML instance that you want to associate with the XSD or DTD. This field does
not appear if the XSD or DTD is the first source document you add to the XQuery
mapper Stylus Studio uses the XML Source document specified in the Scenario
Properties dialog box as the XML instance in this case.
Note
5.
818
a.
Select the element from the XSD or DTD document that you want to use as the
root element. The Choose root element drop-down list displays elements defined
in the document you selected in Step 3.
b.
c.
Click OK.
The document appears in the source document pane of the Mapper tab. Go to
Step 5.
Right click the source document whose association you want to change.
The source document shortcut menu appears.
2.
Click Associate With, and then select the document you want to associate with the
source document.
Remove any maps from the source document to the target schema. (See Removing
Source-Target Map if you need help with this step.)
2.
3.
819
By default, only the file name itself is displayed; if you want, you can display the
documents full path by selecting Show Full Path on the documents shortcut menu.
(Right-click on the document name to display the shortcut menu.)
Source documents are displayed using the tree view; you can use your keyboards *, +,
and - number pad keys to expand and collapse selected documents.
Meaning
Repeating element
Element
Attribute
See Source icons to learn about the different ways source document icons are depicted.
Tip If a node is required by the XML Schema or DTD associated with the target document,
820
You can select an existing document from which Stylus Studio infers a structure and,
optionally, modify the structure. Existing nodes in a target structure are displayed in
blue. Nodes that you add are displayed in red. If a node is required by the associated
XML Schema or DTD, a red check appears over the node symbol.
You can build a structure from scratch, starting with the root element and defining
other elements and attributes as needed. Nodes for target structures you define are
displayed in red.
This section covers the following topics:
2.
Click the Set Target Document button at the top left of the Mapper tab.
The Open dialog box appears.
3.
Select the document you want to use to provide the target structure for defining the
XQuery.
4.
Click Open.
The structure of the document you select appears in the target document pane of the
Mapper tab.
821
2.
Right click the area underneath the Set Target Document button.
The target document shortcut menu appears.
3.
Note
822
1.
2.
Select the attribute or element to which you want to add a child element or attribute.
If you have just created a root element, select the root element.
3.
Right click the area underneath the Set Target Document button.
The target document shortcut menu appears.
4.
Add Attribute
Insert Element After (This choice is not applicable to the root element; it creates
the element as a sibling of the selected element.)
Adding a Node
Removing a Node
Adding a Node
See How to create elements and attributes.
Removing a Node
Note Before you can remove a node, you must delete any links to that node. See Removing
Source-Target Map.
To remove a node from the target structure:
1.
Remove any links to the node you want to remove from the target structure. See
Removing Source-Target Map if you need help with this step.
2.
823
Stylus Studio displays a red letter T for nodes for which you define a text value:
Right-click the node for which you want to set the text value.
The shortcut menu appears.
2.
Type the string you want to use as the text value and click OK.
824
825
If you use the right mouse button, Stylus Studio displays a shortcut menu that provides
you with alternatives for modifying the target structure.
Figure 337. Linking Using the Right Mouse Button Displays a Shortcut Menu
Using this menu, you can easily perform many operations. For example, you can
Map a source document node to an existing target structure node this menu choice,
Map to This Node, is the same as creating the link using the left mouse button.
Add a source document node as a child element of the target structure node you select
and map the two nodes.
Add a source document node as a sibling of the target structure node you select and
map the two nodes.
Copy the entire source document node its structure and its content to the target
structure and map it.
826
1.
Using either the left or right mouse button, drag the source document element or
attribute to the appropriate node on the target structure.
2.
When the pointer is on the appropriate target element, release the mouse button to
complete the link.
Thin
Dashed
Thick
The sample files used to illustrate these styles are books.xml and catalog.xml, from the
Stylus Studio examples\simpleMappings directory.
Thin line
A thin line indicates that the XQuery code generated by Stylus Studio copies content from
the source node to the target node. Such a line is created when you map one element or
attribute to another using the left mouse button, or any of the following choices on the map
shortcut menu:
In addition, the structure required to navigate to the node is also generated if it does not
already exist in the XQuery. For example, consider the map between the title element in
books.xml and the Title element in catalog.xml:
827
This map results in Stylus Studio composing the following XQuery code:
<Catalog>
<Book>
<Title>
{/books/book/title/text()}
</Title>
</Book>
</Catalog>
828
Notice that the FOR loop returns only structure (shown in italics), not content. To add
content, we could also map the title element to the Title element, which results in the
following:
<Catalog>
{
for $book in /books/book
return
<Book>
<Title>
{$book/title/text()}
</Title>
</Book>
}
</Catalog>
Of course, the FLWOR block can be used to define much more complex expressions,
involving maps from source document nodes to its WHERE and ORDER BY ports, for
example.
Thick line
A thick line indicates that the XQuery code generated by Stylus Studio replicates the
complete structure and content of the source document node in the target. Such a map is
created when you use the Copy Node choice on the link shortcut menu. Consider the
following map the bookid attribute on the source was copied to the target as a child of
the Book repeating element:
829
For this type of map, Stylus Studio creates the XQuery code required to duplicate the
source structure and content in the target, as shown in the following sample:
<Catalog>
<Book>
{/books/book/@bookid}</Book>
</Catalog>
Notice that the bookid attribute is displayed in gray in the target structure pane. This
indicates that you cannot edit it.
Select the line that represents the map you want to delete.
Select the portion of the line that is drawn on the XQuery mapper canvas.
Note
2.
830
Stylus Studio.
You can hide links for nodes that are not currently visible in the Source Document or
Target Document pane by clicking the Hide Links for Nodes that are not Visible button,
as shown in Figure 342:
Links in the Mapper canvas only if both nodes are currently visible in the document
panes
831
Green arrows (like the ones shown in Figure 343) in the document panes if only one
of two linked nodes is currently visible.
Exporting Mappings
You can export a mapping source and target document trees and Mapper canvas contents
as an image file. The default image format is JPEG (.jpg), but you can choose from
other popular image file formats such as .bmp and .tiff.
The exported image reflects the document trees at the time you export the image if you
have collapsed a node in Stylus Studio, for example, that node is also collapsed in the
exported image. However, the exported image includes the entire document tree and
Mapper canvas, not just what is currently visible on the Mapper tab.
By default, all source-target document links are displayed. However, if you have chosen
to hide or show links for only certain nodes, the exported image reflects that choice and
displays only the links for the nodes as you have specified. See Simplifying the Mapper
Canvas Display on page 830 for more information on hiding and showing links.
832
Optionally, hide links for any nodes in the source or target documents that you do not
want to appear in the exported image.
2.
Select XQuery > Export Mapping as Image from the Stylus Studio menu.
Stylus Studio displays the Save As dialog box.
3.
4.
Optionally, change the image type. (The default is JPEG; .bmp and .tiff are also
available.)
5.
Click Save.
You can restrict your search to elements and/or attributes, and you can even search using
regular expressions to define your match pattern.
To display the Find dialog box:
1.
2.
FLWOR Blocks
This section describes how to work with FLWOR blocks in the XQuery Mapper tab. It
covers the following topics:
833
Where port
The input for the Where port must be the output port of another block, such as a condition,
IF, or function block. Imagine you have two source documents you can create an Equal
condition block, and specify that the content of an element in one source document must
match the content of an element in the other source document, and map the return value
834
of this condition to the Where port on the FLWOR block. Creating an Equal condition that
specifies that the bookid attribute must be equal to the title element results in Stylus
Studio generating the following XQuery code, for example:
<Catalog>
{
for $book in /books/book
where $book/@bookid = $book/title
order by $book/@pubdate
return
<Book/>
}
</Catalog>
See IF Blocks and Function Blocks for information on using other types of blocks in
XQuery mapper.
Flow port
The Flow port, which is also present on IF and function blocks, allows you to link the
result from other FLWOR, IF, and function blocks to define a conditional execution order
for your XQuery expressions. You might decide you want a particular For each statement
executed only after performing a certain function, for example. Inputs for the Flow port
include the Return port of IF, function, and other FLWOR blocks.
Right-click on the mapper canvas and select New | FLWOR Block from the shortcut
menu.
835
Function Blocks
Stylus Studio supports standard functions defined by the W3C and any user-defined
functions you might have created. This section describes how to work with function
blocks in Stylus Studio and covers the following topics:
User-Defined Functions
anyURI
Accessor
Aggregate
Boolean
Context
DataDirect XQuery
Date/time, duration
Error
Node
Numeric values
QName
Sequence
Sequence generator
Special constructor
String
Trace
If a standard function does not provide the functionality you need, create a user-defined
function. See User-Defined Functions.
836
2.
Select New > Function Block from the shortcut menu. Available functions are
displayed in submenu categories.
2.
Input ports
Input ports are on the left side of the function block. The number and definition of input
ports varies from function to function. To specify a value for an input port, drag a source
document element or attribute to the port and release it.
Flow port
Flow ports, on the top of function blocks, are the same for FLWOR, function, and IF
blocks. See Flow port.
837
Return port
The Return port is on the right side of the function block. You use the Return port to map
the function result directly to a target structure element or attribute, or to a FLWOR, IF,
condition, or another function block.
User-Defined Functions
You can declare your own functions in XQuery. Such functions are referred to as userdefined functions. For more information, see User-Defined Functions on page 844.
concat() as string allows you to specify a literal value that you might wish to
concatenate to some other value in your XQuery.
you to
Note that only the first two input ports are associated with variables ($op1 as string?
and $op2 as string?). When you map a value to the third input port (...), Stylus
Studio automatically adds a fourth input port to allow you concatenate a fourth value.
This behavior is repeated for each additional string you define.
838
IF Blocks
IF blocks have a single input port, labeled condition; a Flow port; and two result ports: if
then, and if else.
<Book>
{
if( $book/title ) then
<Title/>
else
<ISBN/>
}
</Book>
The title element in the source document to the IF blocks input port.
The if then result port to the Title element in the target structure.
The if else result port to the ISBN element in the target structure.
IF blocks create a structure if the if then or if else branches are true. These ports can
be connected to the target schema; otherwise they can be connected to Flow ports of
FLWOR, function, and other IF blocks.
Condition Blocks
The Stylus Studio XQuery mapper allows you to graphically define the following types
of conditions:
Equal (=)
839
All condition blocks have two input ports and a single Return port, as shown in this
example of a greater than block.
You can map the Return port to a target structure element or attribute, or to the input port
on a FLWOR, function, IF, or another condition block.
Predicate Blocks
A predicate allows you to filter data returned from an XQuery. For example, in books.xml,
you might want to return only those books whose bookid attribute was within a specified
range of values. In Stylus Studio, you can display (and create) predicates as predicate
blocks in XQuery Mapper.
A predicate block in XQuery Mapper is rendered as a pair of binoculars. It has two input
ports Context (shown as data in the predicate blocks tool tip) and Expression and a
single Return port, as shown in this example of a greater than block.
840
2.
3.
Ensure that predicates have been enabled in Stylus Studio. See Enabling Predicate
Blocks on page 840 if you need help with this step.
2.
3.
4.
5.
Example
Following is a simple example that selects all books books.xml whose bookid attribute
equals 2. This example uses the books.xml and catalog.xml files in the simpleMappings
folder in the examples project.
1.
Ensure that predicates have been enabled in Stylus Studio. See Enabling Predicate
Blocks on page 840 if you need help with this step.
2.
3.
4.
Drag and drop books.xml to the Add Source Document pane, and drag and drop
catalog.xml to the Set Target Document pane.
5.
6.
Right-click the Mapper canvas and select Conditional Block > XPath predicate.
The predicate block appears on the Mapper canvas.
841
Since we want to look for all book elements, drag book to the predicate blocks Context
port.
Next, we use the conditional block to create predicate expression (that is, only those
book elements whose bookid attribute equals 2).
8.
9.
10.
Double-click the second port on the equal block and specify 2 for the value.
11.
Drag the output port on the equal block to the expression port on the predicate block.
12.
Finally, drag the output port on the predicate block to the control port on the link
connecting title to Title.
At this point, your diagram should look something like this.
As you can see, Stylus Studio created the predicate, [./@bookid = 2], as part of the
XPath expression used to query books.xml. (Note that we defined the document using
the variable $a to simplify the XPath expression.)
842
).
INSERT
UPDATE
DELETE
For more information about using SQL blocks to create XQuery code, see Updating
Relational Databases on page 866.
843
User-Defined Functions
A user-defined function is an XQuery function that you define. Consider the following
example, which illustrates the total-price user-defined function:
declare function total-price( $i as element) as xs:decimal
{
let $subtotals := for $s in $i return $s/quantity * $s/USPrice
return sum( $subtotals )
};
The total-price user-defined function takes an inventory element as its argument and
returns a sum reflecting the dollar value of that inventory (quantity * price). Here is an
example of how it might be used (the user-defined function is shown in italics):
<Catalog>
{
for $book in /books/book
return
<Book>
<Price>
{total-price($book/@bookid)}
</Price>
</Book>
}
</Catalog>
When you create a user-defined function, Stylus Studio adds it to the New > User
Functions shortcut menu available when you right-click the mapper canvas.
This makes it easy to reuse a user-defined function on the Mapper tab once it has been
defined in the XQuery source. See Building an XQuery Using the Mapper on page 813
for more information.
Another way to use user-defined functions is to include them in a library module. You can
then import this library module into other XQuery instead of rewriting the user-defined
844
User-Defined Functions
function each time you need it. See Working with XQuery Library Modules on
page 882
Replaces the code you selected with a function call to the user-defined function
To create a user-defined function:
1.
In the XQuery Source tab or the Text pane of the XQuery Mapper tab, select the
fragment you want to use to create your user-defined function.
845
Consider the following example, which uses the createFullOrder.xquery that is part
of the pipelines example project installed with Stylus Studio.
Drag select the code you want to use to create the user-defined function.
3.
846
User-Defined Functions
Click OK to use the default name, or type any valid name you choose and then click
OK.
The function declaration and a call to that function are added to your XQuery code.
For example:
847
Go to definition
Rename
Tip You can use all of these tools for variables defined in your XQuery code.
848
1.
2.
3.
User-Defined Functions
Stylus Studio displays a teal bookmark adjacent to each occurrence of the user-defined
function, including the line on which the user-defined function is declared.
2.
Right-click.
3.
849
2.
Right-click.
3.
Create a connection to the database server whose tables and/or views you want to
query. You create database connections from the File Explorer window.
2.
Register the database connection with your XQuery file. This process allows the
databases tables and views to be used in your XQuery code.
3.
Invoke the collection() function in your XQuery code. You can type the
collection() statement by hand, or have Stylus Studio create it for you.
4.
Ensure that the processor specified in the XQuery scenario is the DataDirect
XQuery processor.
Database Connections
The database connection is established when the XQuery code is executed and closed as
soon as a result is returned. Connection settings used are those associated with the data
source used to create the XQuery. See Creating a Database Connection on page 852 for
more information on this topic.
851
Supported Databases
Supported Databases
Stylus Studio provides support for the following relational databases:
IBM DB2
Informix
MySQL
Oracle
PostgreSQL
Sybase
For specific version support, see
http://www.datadirect.com/products/xquery/matrix/ddxquery.htm.
Drivers for most of these databases are bundled with Stylus Studio. For some, like
PostgreSQL, for example, you need to specify the classpath for the database driver.
852
Settings vary from database to database, but they typically include the following:
You use the Database Type field to specify the database to which you want to connect.
See Supported Databases for a complete list.
If you are using the PostgreSQL databases, you need to specify the location of the
JDBC driver for that database in the Driver Classpath field. (Drivers for other
relational databases are bundled with Stylus Studio.)
The server URL and other connection parameters. In addition to the servers location,
connection parameters can include the server name, the port through which the
connection is established, and other information, such as a server ID (SID). See Using
the Server URL Field for more information.
You use the Username and Password fields to specify the database user you want to
associate with this data source.
Server address
Port
Database name
853
The specific syntax of the string you enter in the Server URL field varies based on
database type. Consult your database documentation for information regarding
connectivity syntax and optional parameters.
Tip Stylus Studio populates the Server URL field with a default string appropriate for the
database you specify in the Database Type field.
Display the File Explorer window if it is not already open (View > File Explorer).
2.
In the File Explorer window, right-click the RelationalDB icon and select New Server
from the short-cut menu.
Stylus Studio displays the Connection Settings dialog box.
854
3.
Specify the information needed to create the database connection. See The
Connection Settings Dialog Box if you need help with this step.
4.
Did you select a database in the Database Type field for which you must specify a
driver?
If yes, go to Step 5.
If no, go to Step 6.
5.
When you select a database in the Database Type field for which you must specify a
driver, the Driver Classpath field becomes enabled. To specify the driver location:
Figure 364. Set Classpath for the JDBC Driver Dialog Box
b.
c.
To add a JAR file to the classpath, click the browse jar files button (
Stylus Studio displays the Browse for Jar Files dialog box.
).
855
).
6.
d.
When you have located the JAR file or folder you want to add to the classpath,
click OK.
The file appears in the Locations list box of the Set Classpath for the JDBC
Driver dialog box.
e.
Click OK.
The JAR file or folder appears in the Driver Classpath field of the Connection
Settings dialog box.
856
Display the File Explorer window if it is not already open (View > File Explorer).
2.
In the File Explorer window, right-click the server connection whose settings you
want to change and select Edit Server from the short-cut menu.
Stylus Studio displays the Connection Settings dialog box. The current connection
settings are displayed.
3.
You can always edit collection() functions created by Stylus Studio. As long as they
refer to an object that is available based on the database connection associated with the
XQuery, the collection() function will execute successfully. See Choosing a Database
Object on page 862 for more information on this topic.
857
Automatically creates the collection() statement in the XQuery code based on the
table or view you selected
Registers with the XQuery the connection information for the database associated
with the selected table or view, and displays the database in the schema pane of the
XQuery Editor, as shown here:
Editing pane
Schema pane
Once the database connection information is registered with the XQuery, you can expand
the database nodes in the schema pane to display individual table and view columns.
858
Adds a new connection, if the object was from a different server or port
Modifies the existing connection, if the object is from the same server and port
A new collection() statement is created for each object you drop on the editing pane of
the XQuery editor.
Open a new XQuery if one is not already open. The XQuery Source tab should be
displayed.
2.
859
In the File Explorer window, expand the database and tablespace to display the tables
or views you want to access in your XQuery, as shown in this example:
Optionally, display table and view columns by selecting Read Structure from the
table or view shortcut menu (right-click).
4.
860
Drag the desired table or view and drop it on the editing pane of the XQuery Source
tab.
Optionally, drop the table or view on the schema pane of the XQuery Source tab. If
you do this, you must then drag the desired table or view from the schema pane to the
editing pane to create the collection() statement.
Stylus Studio creates the collection() statement based on the table or view you
selected in Step 4. It also displays the tables or views database in the schema pane
of the XQuery Editor (see Figure 368).
This also gives you the ability to close the File Explorer window after creating your
database connection providing more room to work, and simplifying the Stylus Studio
desktop display.
Tip You can also gain access to column-level information about a databases tables and views
directly from the File Explorer window by selecting Read Structure from the table or
861
Server all of the servers databases and their child tables and views can be queried
Database all of the databases tablespaces and their child tables and views can be
queried
862
Example
Consider the books.xml file that is installed with the simpleMappings project installed
with Stylus Studio. This is what the books.xml file looks like when displayed using the
XML Editors Grid tab.
In this example, well use a zipped copy of books.xml, books.zip, as the source for a
simple XQuery that will return information for all books with some variant of begin in
their title.
We start by creating a new XQuery, which we save as zip_source.xquery. To start the
mapping process, we click the Mapper tab. Next, we can select the source and target
documents required for our XQuery.
When you click the Add Source Document button, Stylus Studio displays the Open
dialog box. You can use the Files of drop-down menu to filter the types of files. As you
863
can see, Stylus Studio supports numerous document types based on the Zip Archive
format.
Figure 372. Stylus Studio Supports Numerous Zip Archive File Formats
Well choose the books.zip file we created previously. (Of course, you can drag source
and target files from your file systems and drop them directly on the source and target
document panes.) Once the .zip file is added as a source, we can navigate it just as we
would any other XML file:
Next, we add catalog.xml from the simpleMappings project as our target document.
864
Well use a FLWOR expression to iterate over the source XML. Mapping the contents of
a zipped XML file is just like mapping plain XML just expand the tree to locate the node
you want to map, drag, and drop. In this case, we drag the book repeating element from
the zipped books.xml and drop it on the Book repeating element in the target document.
Stylus Studio creates the FLWOR block automatically when mapping one repeating
element to another.
Next, we create a contains function to select only those books that have the string Begin
as part of their title. Right-click the mapper canvas and choose Function Block >
Functions on Strings > contains/2 from the short-cut menu. Stylus Studio adds the
contains function to the Mapper canvas. To specify the contains function, we map the
title element to the first input port on the contains function block ($arg1 as xs:string?).
To specify the partial string we want to search for, we double-click the second input port,
and enter Begin in the Value dialog box. When were done, we map the contains
function output port to the Where port on the FLWOR block.
Finally, we map the title element in the zipped source XML to the Title element in the
target XML. When we preview the XQuery, we can see that Stylus Studio was able to read
865
the zipped XML document and provide the titles for all the books that contain some
portion of the string Begin.
866
Overview
In XQuery Mapper, simple drag-and-drop techniques create calls to built-in DataDirect
XQuery functions ddtek:sql-insert, ddtek:sql-update, and ddtek:sql-delete that
perform update operations on relational databases. For example, this XQuery code, which
performs an INSERT operation on the Products table, was created with a few simple
mappings:
ddtek:sql-insert("sqlserver_pcipeduzz
:Northwind.dbo.Products",
"ProductName",$Products/ProductName,
"SupplierID",$Products/SupplierID,
"CategoryID",$Products/CategoryID)
Stylus Studio provides support for numerous relational databases, including Microsoft
SQL Server, Informix, and Oracle. For a complete list, see Supported Databases on
page 852.
For information on connecting to a relational database, see Creating a Database
Connection on page 852.
The first port on the left is colored because it already has a value it is the table used to
create the SQL update block; "myServer:pubs.dbo.authors", for example. The other two
ports are column name/value pairs. They are empty because they do not contain values
when the function call is first created. You provide these values by mapping, or, in the case
of update functions, by explicitly providing a value for the port by double-clicking it.
867
To map column name/value pairs, you first expand the SQL function block by doubleclicking it. When you double-click a SQL function block, it expands to show the table
name and each of the columns that make up the table:
Each column has an associated port. You use these ports to map nodes from XML data
sources in the Add Source Document pane. Always perform mapping operations using
the ports on the expanded SQL function block when you are building your XQuery using
the XQuery Mapper.
For a summary of SQL function blocks, see SQL Function Blocks on page 843.
868
For general information on mapping, see Building an XQuery Using the Mapper on
page 813.
Drag-and-drop
Connect to the relational database that contains the table or tables you want to update.
See Creating a Database Connection on page 852 if you need help with this step.
2.
In the File Explorer, expand the database tree to expose the table you want to update.
3.
Drag the table from the File Explorer and drop it on the Mapper canvas.
A short-cut menu appears with two choices: Create SQL Insert Call and Create SQL
Update Call.
4.
5.
Create a FLWOR block to loop over the database table. See Creating a FLWOR
Block on page 835 if you need help with this step.
6.
Map the output of the FLWOR block to the flow port on the top of the function block.
7.
8.
Map source document nodes to the corresponding input ports on the function block.
9.
Save and preview the XQuery; check results on the database table you have updated.
869
Alternative:
1.
2.
Select Function Block > DataDirect XQuery > sql-insert from the short-cut menu.
The insert function block appears on the Mapper canvas.
3.
When you have finished defining the XQuery, map the insert function blocks output
port to the Set Target Document pane. Your XQuery mapping is not committed to
Stylus Studio until you complete this step.
Example
In this example, we use the SQL insert function call to add a new set of records to the
Products table.
In a new XQuery that we have saved as INSERT.xquery, we drag the Products table and
drop it on the XQuery Mapper canvas. After choosing Create SQL Insert Call from the
short-cut menu, the database table is automatically added as a source for the XQuery, and
that the outline for the DataDirect XQuery ddtek:sql-insert function is displayed in the
Mappers text pane:
870
Next, we create a FLWOR block (right-click on the Mapper canvas and select FLWOR
Block) to loop through all the records in the Products table. We use the Products repeating
element to specify the FLWOR blocks Where clause, and map its output to the flow port
on the SQL block. Again, notice that the XQuery code displayed in the text pane is
updated with the code for the FLWOR block:
Values for new records can come from existing records if they are mapped; otherwise,
they are created as empty records or use default values depending on how the database is
configured.
For this example, lets use existing values for the ProductName, SupplierID, and
CategoryID columns. In order to map these values, we first expand the SQL block created
871
for the Products table by double-clicking it, and then mapping the element names in the
Add Source Document pane to the corresponding ports on the SQL block:
Figure 380. Mapped Columns Use Existing Values for New Records
872
Before we preview the XQuery, lets take a look at the Products table on the database. If
we double click the Products table in the File Explorer, Stylus Studio renders the table as
an XML document.
Using a simple XPath expression (count(//Products)), we can see that there are 77
records in the Product table. When we preview the XQuery, we can see that 77 new
records have been added to the Products table, for a total of 154:
873
Drag-and-drop
Connect to the relational database that contains the table or tables you want to update.
See Creating a Database Connection on page 852 if you need help with this step.
2.
Drag the table you want to update from the File Explorer and drop it on the XQuery
Mapper canvas.
3.
Map the repeating element that represents the table you want to update to the first
input port ($row-node as element()*).
4.
Create a FLWOR block to locate the record you want to update in the database table.
See Creating a FLWOR Block on page 835 if you need help with this step.
5.
Map the output of the FLWOR block to the flow port on the top of the update function
block.
6.
Create a condition expression to select the records you want to update. See Creating
a Function Block on page 837 if you need help with this step.
7.
8.
Double-click the input port that corresponds to the column whose value you want to
change.
9.
Save and preview the XQuery; check results on the database table you have updated.
Alternative:
874
1.
2.
Select Function Block > DataDirect XQuery > sql-update from the short-cut menu.
The update function block appears on the Mapper canvas.
When you have finished defining the XQuery, map the update function blocks output
port to the Set Target Document pane. Your XQuery mapping is not committed to
Stylus Studio until you complete this step.
Example
In this example, we update the Shippers table to change the telephone for the Speedy
Express company.
If we double-click the Shippers table in the File Explorer, the Shippers table is rendered
as XML. Looking at Grid tab, we can see that the Shippers table has three records, and
that the current telephone number for Speedy Express is (503) 555-9831.
To get started, we create a new XQuery and save it as UPDATE.xquery. As with the insert
function, we drag and drop the table from the File Explorer and drop it on the XQuery
Mapper canvas. After dropping the table, choose Create SQL Update Call from the shortcut menu to add the SQL block and the corresponding code to the XQuery.
In order to update a record, we need to:
875
First, we map the Shippers repeating element to the first port ($row-node as element()*)
on the SQL block created for the update function. This creates a collection based on the
Shippers table. (See Using the collection() Function in Stylus Studio on page 851 for
more information on collections.)
Next, we create a FLWOR expression to iterate over the Shippers table by mapping the
Shippers repeating element to the For port on the FLWOR block, and mapping the
FLWOR blocks output port to the flow port on the SQL block. At this point, our XQuery
Mapper canvas, and the resulting XQuery code, looks something like this:
Next we need to specify which record we want to update, and how we want to change it.
Well do this by creating a simple condition expression that locates the shipper whose
phone number we want to change (the ShipperID for Speedy Express is 1). To do this, we
Double-click the second input port to specify the ShipperID value for the record we
want to update
876
As you can see from the resulting XQuery code, the update function still needs values
specified for the column in the Shippers table we want to update, and the new value
To specify values to update the Shippers table, we first double-click the SQL update block
to expose the ports for each of the tables columns, and then double-click the Phone port:
Figure 386. Specifying the New Value for the Phone Column
877
If we preview the XQuery and then check open Shippers table as XML in Stylus Studio,
we can see that the telephone number has been updated from (503) 555-9831 to
(503) 555-3099:
Map the function blocks output port to the Set Target Document pane.
878
1.
2.
Select Function Block > DataDirect XQuery > sql-delete from the short-cut menu.
The delete function block appears on the Mapper canvas.
3.
Drag the table you want to update from the File Explorer and drop it on the Add
Source Document pane.
Create a FLWOR block to iterate over the table to locate the records you want to
update. See Creating a FLWOR Block on page 835 if you need help with this step.
5.
Create a condition expression to select the records you want to update. See Creating
a Function Block on page 837 if you need help with this step.
Example
In this example, we delete one of the products from the Products table, Queso Cabrales,
as it as been discontinued by the supplier. As shown in the following illustration, Queso
Cabrales corresponds to ProductID 11 in the Products table:
In a new XQuery we save as DELETE.xquery, we first add the Products table to our
XQuery by dragging it from the File Explorer and dropping it on the Add Source
Document pane. We start building the XQuery by creating a FLWOR block; well use the
FLWOR expression to iterate over the Products table to locate the record we want to
delete. When the FLWOR block is added, we map the Products repeating element to the
FLWOR blocks For port.
879
Next, we add a simple condition expression that locates the Product table record by
matching the ProductID to the value of the record we want to delete (the ProductID for
Queso Cabrales is 11). We can then map the output of this condition expression to the
Where port on the FLWOR block.
Finally, we add the SQL delete function by right-clicking the Mapper canvas and selecting
Function Block > DataDirect XQuery > sql-delete from the short-cut menu. (SQL delete
functions cannot be created using drag-and drop.) We map the FLWOR blocks output
port to the flow port on the top of the SQL delete function block, and map the Products
repeating element to the SQL delete function blocks input port. At this point, our XQuery
looks something like this:
Notice that the text pane of the XQuery Mapper is blank. This is because the mapping has
not been committed to Stylus Studio. To commit a mapping to Stylus Studio, you simply
map the function blocks output port to the Set Target Document pane. This mapping,
which is completed automatically for you by Stylus Studio when you create SQL insert
and update functions using drag and drop, is needed to commit the XQuery mapping to
Stylus Studio; as with SQL insert and update functions, no output results from a SQL
delete function. Any changes specified in the XQuery occur directly on the database.
880
When we commit the XQuery mapping to Stylus Studio, our XQuery code appears in the
text pane, as shown here:
881
After we preview the XQuery, we can see that the record for Queso Cabrales has been
deleted from the Products table:
882
Consider the following example of a simple XQuery library module that contains two
user-defined functions total-price and titleQuantity:
module namespace ns = "urn:utils";
declare function ns:total-price( $i as element) as xs:decimal
{
let $subtotals := for $s in $i return $s/quantity * $s/USPrice
return sum( $subtotals )
};
declare function ns:titleQuantity($GROUP_28, $row)
{
<book>
<title>
{$row/title/text()}
</title>
<quantity>
{$GROUP_28/QTY/QTY01/QTY0102/text()}
</quantity>
<ISBN>
{$GROUP_28/LIN/LIN03/LIN0301/text()}
</ISBN>
</book>
};
You create an XQuery library module by typing the module definition in the XQuery
editor. If you copy/paste user-defined functions from other XQuery, make sure to change
the namespace prefix for each user-defined function as described in the following section,
About Namespaces on page 883.
About Namespaces
An XQuery library module requires a namespace definition. You can specify the
namespace using
883
Open the XQuery into which you want to import the library module.
2.
3.
Right-click the Mapper background and choose Imported Modules from the short-cut
menu.
The Imported Modules dialog box appears.
If the XQuery already has an imported library module, its information is displayed.
884
4.
5.
Locate the XQuery that contains the library module definition and click OK.
The library module appears in the Imported Modules dialog box; the Namespace field
displays the library modules namespace; the Location field displays its path.
885
All user-defined functions that are specified in any library modules you have imported are
available from the User Defined Functions short-cut menu, as shown in the following
illustration:
886
1.
2.
In the Imported Modules dialog box, select the library module you want to remove.
3.
4.
Click OK.
The import statement is removed from your XQuery.
Debugging XQuery
Alternative
To remove an imported module from your XQuery, delete the code directly in the XQuery
editor.
Debugging XQuery
Complex XQuery requires robust debugging tools.
Trace the sequence of XQuery expressions that created output. With a click anywhere
in the result, Stylus Studio Visual Backmapping technology displays the XQuery
expression responsible for creating that result.
887
Using Breakpoints
Using Bookmarks
Profiling XQuery
Using Breakpoints
The Stylus Studio debugger allows you to interrupt XQuery processing to gather
information about variables and XQuery expression execution at particular points.
Inserting Breakpoints
To insert a breakpoint:
1.
In the XQuery in which you want to set a breakpoint, place your cursor where you
want the breakpoint to be.
2.
Removing Breakpoints
To remove a breakpoint:
1.
2.
Start Debugging
When your XQuery has one or more breakpoints set, start processing by clicking Start
or pressing F5. When Stylus Studio reaches the first breakpoint, it
Debugging
suspends processing and activates the debugging tools. After you examine the
information associated with that breakpoint (see Viewing Processing Information on
page 889) you can choose to
Debugging XQuery
889
Information about how the return value (displayed in the Variables window as
__Return_Value_3, for example) is being built
890
Debugging XQuery
Using Bookmarks
When you are editing or debugging a long file, you might want to repeatedly check certain
lines in the file. To quickly focus on a particular line, insert a bookmark for that line. You
can insert any number of bookmarks. You can insert bookmarks in any document that you
can open in Stylus Studio.
Inserting
To insert a bookmark:
1.
2.
Removing
To remove a bookmark:
1.
Click in the line that has the bookmark you want to remove.
2.
Click Toggle Bookmark in the Stylus Studio tool bar. Stylus Studio removes the
turquoise box.
Moving Focus
To move from bookmark to bookmark, click Next Bookmark
Bookmark
.
or Previous
891
Profiling XQuery
XQuery profiling is available only in Stylus Studio XML Enterprise Suite.
In addition to debugging tools for XQuery, Stylus Studio provides the XQuery Profiler, a
tool that helps you evaluate the efficiency of your XQuery. By default, the performance
metrics gathered by the XQuery Profiler are displayed in a preformatted report, like the
one shown here:
The report format is controlled by the default XSLT stylesheet, profile.xsl, in the \Stylus
Studio\bin directory. You can customize this stylesheet as required. You can save XQuery
892
Debugging XQuery
In addition to generating the standard XQuery Profiler report, you can save the raw data
generated by the Profiler and use this data to create your own reports. See Enabling the
Profiler for more information about this procedure.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XQuery Profiling video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
the XQuery itself. Consider using the Profiler with the first two performance metric
options. You can also use the Limit Trace To fields to further restrict the Profilers scope.
If you find you need still more detail (while troubleshooting a performance bottleneck,
for example), use the step-by-step setting.
Open the Scenario Properties dialog box for the XQuery. (Click Browse
top of the XQuery editor window.)
at the
893
Select the settings for the performance metrics you want the Profiler to capture.
4.
Note
5.
Click OK.
The next time you preview the XQuery results, the performance metrics you selected
are available to you in the XQuery Profiler report (and as raw data if you selected that
setting and specified a file).
894
1.
Ensure that the Profiler is enabled. (See Enabling the Profiler if you need help with
this step.)
2.
3.
).
895
In the following query plan, notice how the Relational Data Source node includes details
about the SQL Select statement, as well as information about how the result ($PT) is
constructed.
896
In addition to the Plan node, the query plan tree can include Adaptors, Global Variables,
and Local Functions nodes. These nodes are described in the following table.
Table 106. Query Plan Nodes
Node
Description
Adaptors
Global Variables
This node contains a list of global variables that are available to the
query plan, such as external variables defined by the query and
variables defined as part of the generation of the execution plan.
Local Functions
Plan
Navigation
You can navigate the tree to check where variables are defined and where they are
referenced. For example, you can navigate from one adaptors definition to its references
and vice-versa.
To navigate the tree, you can
897
Description
Go to definition: given a selected variable reference, go to the
position in the plan where the variable is defined.
Go to first reference: given a selected variable definition, go to its
first reference in the plan.
Go to next reference: given a selected variable reference, go to the
next reference of the same variable (if any).
Go to previous reference: given a selected variable reference, go to
the previous reference of the same variable (if any).
Formatting
You can change the font size used to display query plan text and symbols by right-clicking
a tree node and selecting the font size you wish to use. Changes to font size affect the
entire query plan, but they are not saved when you save the query plan as HTML.
898
1.
Select XQuery > Save Plan as HTML from the Stylus Studio menu.
Alternative: Click the Save Plan button on the Plan tab.
The Save As dialog box appears.
2.
3.
Click Save.
Prerequisites
In order to display a query plan in Stylus Studio, you need to specify the DataDirect
XQuery processor for your XQuery. See Selecting an XQuery Processor for more
information.
Open the XQuery whose query plan you want to view in the Stylus Studio XQuery
Editor.
2.
Make sure your XQuerys processor is set to the DataDirect XQuery processor. See
Selecting an XQuery Processor if you need help with this step.
3.
for your XQuery code. You might want to run and view this report before making changes
to your XQuery code. See Profiling XQuery for more information.
899
900
You specify XML input on the General tab of the Scenario Properties dialog box.
document you select as the main input XML document, though you can override this
default at any time. See Data Sources to learn more about the process of selecting and
working with XQuery source documents in XQuery mapper.
901
The Raining Data TigerLogic XDMS XQuery processor, which runs on the
TigerLogic XDMS server
one of them as the default XQuery processor. See Setting Default Options for
Processors on page 907.
Using the Saxon Processor
Stylus Studio lets you execute XQuery using either the Saxon-B (basic) or Saxon-SA
(schema-aware) processor. You specify which processor you want to use with the
Execution mode property in the Saxon XQuery Settings dialog box. Settings that have
902
command line equivalents in Saxon show the command in parentheses following the
property name. Some settings are available only if you are using Saxon-SA.
Support for Saxon-SA is available only in Stylus Studio XML Enterprise Suite.
Stylus Studios Sense:X syntax coloring and auto-completion provides full support for
Saxon syntax, so long as the Saxon XQuery processor is either associated with the current
XQuery scenario or has been set as the default XQuery processor.
If you want to use the Saxon processor:
1.
2.
Complete the settings as desired. Press F1 to access the Stylus Studio online help, or
refer to the Saxon documentation for more information.
4.
Click OK.
903
2.
Enter the host, port, username, and password information for the server on which the
TigerLogic XDMS is running.
4.
Click OK.
904
1.
Using the DataDirect XQuery and Java APIs to implement a Java interface for each
of the custom URI resolver types you intend to use.
2.
Registering the Java class for each custom URI resolver with Stylus Studio. You can
do this on a per-XQuery basis using the XQuery Scenario Properties dialog box, or
as a default setting for all XQuery code you write in Stylus Studio using the
Processor Settings page of the Options dialog box.
javax.xml.transform.URIResolver
com.ddtek.xquery.CollectionURIResolver
com.ddtek.xquery.ModuleURIResolver
For more information on implementing a custom URI resolver interface, see the
DataDirect XQuery Users Guide and Reference.
Open the XQuery for which you want to register a custom URI resolver in the Stylus
Studio XQuery Editor.
2.
3.
4.
If DataDirect XQuery is not specified as the processor, use the Processor drop-down
field to change it.
905
906
7.
Navigate the available folders to locate the file that implements the interface for the
type of custom URI resolver you are registering.
8.
9.
2.
Navigate to the Module Settings > XQuery > Processor Settings folder.
Follow Step 4 through Step 8 in the procedure Registering a Custom URI Resolver
on page 905.
You can always override the default processor and default processor settings at the
scenario level.
907
2.
Select the processor for which you want to specify default settings from the
Processor drop-down list.
4.
5.
If you want to use this processor as the default processor for all XQuery scenarios,
click the Use as default processor check box.
6.
Click OK.
908
When you run the scenario, you can specify the parameter value you want to use by
double-clicking the Expression field and typing a value. Valid values are XPath
expressions and must be entered using single or double quotes.
909
2.
In the XQuery Editor, in the scenario name field, click the down arrow and click the
name of the scenario for which you want to perform validation.
3.
Click Browse
4.
910
5.
6.
If you are using Stylus Studios built-in validation engine, optionally, specify the
XML Schemas against which you want to validate the XML result document.
Otherwise, go to Step 7
a.
b.
c.
Click the Open button to add the XML Schema to the Validation tab.
d.
e.
Go to Step 8.
Click the Use custom validator button, and select the validation engine you want to
use from the drop-down list box.
8.
Click OK.
2.
In the Scenario name: field, type the name of the new scenario.
3.
In the Main input: field, type the name of the XML file to which you want to apply
to navigate to an XML file and select it.
the XQuery, or click Browse
If the first document you added to the XQuery is an XML document, Stylus Studio
uses that document as the XML source for the scenario and displays it in this field.
Note
4.
If you are using DataDirect XQuery, specify one or more defined collections as
input. See Specifying XML Input if you need help with this step.
5.
In the Output URL field, optionally type or select the name of the result document you
want the XQuery to generate. If you specify the name of a file that does not exist,
Stylus Studio creates it when you preview the XQuery.
6.
If you want Stylus Studio to store paths relative to the XQuery path, ensure that the
Use relative paths option is checked.
7.
If you check Preview result in an external application, Stylus Studio displays the
result Internet Explorer. In addition, Stylus Studio always displays XQuery results in
the Preview window.
8.
If you want to specify values for XQuery parameters, click the Parameter Values tab.
Click the Variable Name field for the parameter Stylus Studio places the text cursor
in the Expression field, allowing you to type a value for the parameter.
9.
If you want Stylus Studio to capture performance metrics, enable the XQuery Profiler
on the Profiling Options tab. See Profiling XQuery on page 892.
911
To define another scenario, click Add and enter the information for that scenario. You
can also copy scenarios. See How to Clone a Scenario on page 912.
11.
Click OK.
If you start to create a scenario and then change your mind, click Delete and then OK.
2.
Select a scenario from the scenario drop-down list at the top of the editor window.
Alternative:
a.
b.
On the General tab, select the scenario you want to run from the Existing
Scenarios list.
c.
Click OK.
).
912
1.
2.
3.
In the Scenario Properties dialog box, in the Existing preview scenarios field, click
the name of the scenario you want to clone.
4.
Click Clone.
5.
In the Scenario name field, type the name of the new scenario.
Change any other scenario properties you want to change. See How to Create a
Scenario on page 911.
7.
Click OK.
If you change your mind and do not want to create the clone, click Delete and then OK.
913
Documentation Defaults
By default, xqDoc generates Module URI, Function Summary, and Function Detail
sections for each XQuery, as shown in the following illustration.
If you want, you can add your own comments using the syntax described in the following
section, Syntax and Usage on page 914.
Figure 410. xqDoc Report with Additional Module and Function Descriptions
All other comments must precede function declarations. xqDoc uses the text you enter to
provide a description for each function listed in the Function Summary. The same
915
description is used in the Function Detail. Here is an illustration of the XQuery in the
XQuery Editor; the xqDoc comments are highlighted:
ActiveX Controls
xqDoc reports use ActiveX controls for navigation and code sample generation. Make
sure to enable ActiveX controls for the browser displaying the xqDoc report.
916
2.
917
By default, Stylus Studio selects the directory to which the XQuery is saved. After
that, Stylus Studio uses the last location to which you saved the XQuery
documentation.
918
4.
Optionally, change the location to which you want to save the XQuery
documentation.
5.
Click OK.
Stylus Studio displays processing information in the Output window. A new Internet
browser is launched; the XQuery documentation is displayed in this browser.
6.
If you have not already done so, enable ActiveX controls for the browser window
displaying the xqDoc report.
Create a new Web service call and configure the SOAP request as required. See How
to Compose a Web Service Call on page 944 if you need help with this step.
2.
Create XQuery code from the Web service call. See How to Create XQuery from a
Web Service Call on page 959 if you need help with this step.
As a result of this step, XQuery code is copied to your systems clipboard.
3.
Open a new XQuery (File > New > XQuery File). Make sure you use the Saxon or
DataDirect XQuery processor. See Selecting an XQuery Processor on page 902 if
you need help with this step.
4.
5.
Preview the XQuery by clicking the Preview Result button at the top of the XQuery
Editor.
The results of the SOAP request contained in the XQuery appear in the Preview
window.
919
Rules
When invoking multiple SOAP requests in the same XQuery, bear in mind the following
rules:
The XQuery must contain only one instance of the header that declares the namespace
used by the Web service. For example:
declare namespace tns = "http://swanandmokashi.com";
Make sure you understand the rules for including multiple SOAP requests in the same
XQuery code as described in the previous section, Rules on page 920.
2.
Create the Web service call, and use Web Service Call > Copy XQuery Call to
Clipboard to create XQuery code for the SOAP request as described in Creating
XQuery from a Web Service Call on page 958.
The XQuery code created by Stylus Studio is copied to your systems clipboard.
920
3.
Create a new XQuery, and paste the contents of your system clipboard into it.
4.
5.
Repeat Step 2 for the next Web service SOAP request you want to invoke from your
XQuery.
6.
Paste the new XQuery code into the XQuery you created in Step 3. Before pasting,
place the text cursor after the comma you typed in Step 4.
7.
From the XQuery code you just pasted, delete the namespace declaration that
precedes the ddtek:wscall() function.
Stylus Studio User Guide
See Examining the ddtek:wscall Function Block on page 924 for more information.
Automatically, by dragging and dropping a Web service call (.wscc file) on the
Mapper canvas. This method creates the ddtek:wscall function in a single operation
that does not require you to specify the WSDL URL or Web service operation.
Stylus Studio User Guide
921
Use this method when you have created a Web service call using the Stylus Studio
Web Service Call Composer. See , , on page 943 for more information on this topic.
Manually, by choosing the ddtek:wscall function from the XQuery Mapper canvas
short-cut menu (right-click to display). This method requires you to enter the URL for
the WSDL file, which you can do by typing or navigating a file system, and selecting
the Web service operation you want your XQuery code to execute.
Use this method when you want to use Web service operations that have not been
exposed using a Stylus Studio Web service call.
2.
Open the Stylus Studio File Explorer or some other tool that allows you to navigate a
file system.
3.
Locate the Web service call (.wscc file) for the Web service whose operations you
want to include in your XQuery code.
4.
Drag the .wscc file and drop it on the XQuery Mapper canvas.
Stylus Studio adds the ddtek:wscall function glyph to the Mapper canvas and code
for the ddtek:wscall function to your XQuery code.
If the Web service exposes multiple operations, the ddtek:wscall function is created with
the operation that was exposed in the Web Service Call Composer when the .wscc file was
last saved. You can choose the operation you want your XQuery code to execute by
modifying the Web service call in XQuery Mapper:
1.
2.
Click the down arrow in the Operation Name field to display the available Web
service operations, as shown here:
922
2.
Right-click the Mapper canvas and select Function Block > DataDirect XQuery >
wscall/2.
There are two predefined wscall functions wscall/2 provides location and payload
input ports; wscall/3 also provides a header input ports.
Note
Stylus Studio displays the Choose the WSDL Operation dialog box.
Enter the URL of the WSDL whose operation you want your XQuery to execute in
the WSDL File field.
Example:
http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx?WSDL
You can use Stylus Studio to help locate WSDL documents. See Obtaining WSDL
URLs on page 947 for more information.
Tip
Stylus Studio displays the operations associated with the Web service represented by
the WSDL in the Operation Name field.
4.
Choose the Web service operation you want your XQuery to execute from the
Operation Name field.
Example: GetStockQuotes.
5.
Click OK.
923
Stylus Studio displays the wscall function block on the XQuery Mapper canvas.
The illustration shown in Figure 417 shows a wscall defined with location and
payload input ports.
924
If you double-click the port, Stylus Studio displays a configurable information box, as
shown in Figure 418. (The same is true for other input ports and the output port.)
If we right-click the address node and choose Set Text Value, the Value dialog box
displays the URL for the Swanand Mokashi Web service WSDL, as shown in Figure 419:
925
The payload for the Swanand Mokashi StockQuotes Web service, for example, is a
ticker value PRGS, GOOG, or EBAY, for example.
Output Port
The output port for the ddtek:wscall function displays the output of the Web service
represented by the ddtek:wscall function. In the case of the Swanand Mokashi
StockQuote Web service, available output includes company name, stock quote, change,
opening price, and so on, as shown in Figure 419.
926
Note that you can display information for only one input port at a time.
927
When use a ddtek:wscall function, however, you map source and target document nodes
to schema nodes in the port information blocks, as shown in Figure 422.
2.
928
For our source document, well use a simple XML document that contains only a
ticker value PRGS.
For the target, well create a root node (right-click the Set Target Document pane and
choose Create Root Element), and a child element, my_quote.
Before continuing, lets make a quick change to the source document because wed
like to use this XQuery with other sources, we can define the source as a global
variable:
a.
Right-click the source document URL, and choose Associate with > Global
In the Associate Schema with Variable dialog box, we enter ticker_source and
click OK.
Now the document URL appears as $ticker_source, allowing us to easily substitute
other source documents for use with this XQuery.
Stylus Studio specified location, payload, and output ports based on the Web service
we used to create the wscall function block. (Double-click the ports to display this
information.) However, not all of the values required to generate the output we need
the specific company stock ticker we want to look up, and what information about
that stock we want Swanand Mokashi to provide has been specified. Well do that
now.
b.
4.
Double-click the payload port, and map the ticker node from the source document to
the tns:QuoteTicker node in the payload port information box.
The Web service will be given the value of the ticker element from our source
document when the XQuery is run.
929
6.
Since well want multiple pieces of information from the Web service (we want to see
the company name, ticker value, and current stock price in our output), we define a
FLWOR block so that we make one call to the Web service.
Right-click the Mapper canvas and choose FLWOR Block.
Stylus Studio adds a FLWOR block to the XQuery Mapper.
7.
Double-click the output port and fully expand the output port information box.
930
Map the repeating tns:Quote element to the for port on the FLWOR block.
Next, map the FLWOR blocks output port to the my_quote node we created in the
target document.
Now we can choose the output provided by the Web service we want to include in our
XQuery. For the tns:CompanyName, tns:StockTicker, and tns:StockQuote Web service
nodes, we do this drag-and-drop operation:
a.
Using the right mouse button (mouse button 2), drag the node to the my_quote
node in the target document.
b.
When we release the mouse button to drop the Web service node, we choose Add
Child Element and Map It.
c.
We rename the target node, dropping the tns: prefix, in the Name dialog box
when the target document element is created.
931
932
933
The following tables summarizes the scenario properties that affect code generation.
Table 109. Scenario Properties that Affect Code Generation
Tab
Comment
General
The Code Generation wizard uses only the Source XML URL and the
Output URL field, if specified. All other properties on this page are
ignored.
Processor
You can use the following XQuery processors for generating Java code:
DataDirect XQuery
Saxon
Profiling Options
Ignored.
Validation
You can use the following validation engines for validating your XQuery
Java code:
Saxon
Java built-in
If you choose a validation engine that is not supported, Stylus Studio uses
the Java built-in validation engine.
Post-process
934
The target directory in which you want the Java code created. c:\temp\myJavaCode, for
example. If the directory you name does not exist, Stylus Studio creates it when you
run the Code Generation wizard.
The default is a \sources directory created in your Windows user data directory
C:\Documents and Settings\sula\My Documents\Stylus Studio\sources , for
example.
Optionally, a package name. If you specify a package name, this name is used for a
subfolder created in the target directory you specify. If you specify myPackage as the
package name, for example, the generated code is written to
c:\temp\myJavaCode\myPackage. (Though optional, it is considered good practice to
create a package name.)
The class name. Stylus Studio also uses the class name for the .java file created by
the Code Generation wizard. For example, if you provide the name myClass, Stylus
Studio creates c:\temp\myJavaCode\myPackage\myClass.java.
The default class name is taken from the XQuery file name.
Whether or not you want to add the generated code to the current Stylus Studio
project. If you choose to add the generated code to the project, it creates a folder using
the package name you specify and places the .java file in that folder. If you do not
specify a package name, the .java file is added directly below the project root in the
Project window.
Stylus Studio User Guide
935
Whether or not you want to embed the XQuery source in the Java code. Embedding
the XQuery source allows the Java code to run without referencing any external
sources.
Open the XQuery for which you want to generate Java code.
2.
Define at least one scenario for the XQuery. The scenario must use the Saxon or
DataDirect XQuery processor. See Scenario Properties Used for Generating Code
for more information.
3.
Select the scenario for which you want to generate Java code.
4.
5.
Select XQuery > Generate Code > Generate Java Code from the Stylus Studio menu.
The Generate Java Code dialog box appears.
936
6.
Specify the settings you want for the target directory, package and class names, and
so on. See Java Code Generation Settings if you need help with this step.
7.
Click OK.
Stylus Studio generates Java code for the XQuery. When the code generation is
complete, the resulting file (classname.java) is opened in the Stylus Studio Java
Editor.
Saxonsa.jar
ddxq.jar
These files are in the \bin directory where you installed Stylus Studio.
In addition, if your XQuery or XLST code uses DataDirect XML Converters, these JAR
files must also be in your system classpath:
Stylus Studio ensures that these files are added to your classpath when you generate code.
If you plan to compile the generated code outside Stylus Studio, you need to modify your
system classpath yourself.
2.
2.
937
Converters. Licenses for DataDirect XML Converters are purchased separately from
Stylus Studio X14 XML Enterprise Suite.
Similarly, if you use the DataDirect XQuery processor, you must acquire additional
licences if you wish to deploy your XQuery code.
Write Stylus Studio at [email protected], or call 781.280.4488 for more
information.
Java code for XQuery. See Generating Java Code for XQuery
C# code for XSLT. See Generating C# Code for XSLT
938
Comment
General
The Code Generation wizard uses only the Source XML URL and the
Output URL field, if specified. All other properties on this page are
ignored.
Processor
Parameter Values
Profiling Options
Ignored.
Validation
You can use the following validation engines for validating your XQuery
C# code:
Saxon
If you choose a validation engine that is not supported, Stylus Studio uses
the .NET XML parser.
Post-process
939
Optionally, a namespace name. If you specify a namespace name, this name is used
for a subfolder created in the target directory you specify. If you specify
myNamespace as the package name, for example, the generated code is written to
c:\temp\myC#Code\myNamespace. (Though optional, it is considered good practice to
create a namespace name.)
The class name. Stylus Studio also uses the class name for the .cs file created by the
Code Generation wizard. For example, if you provide the name myClass, Stylus
Studio creates c:\temp\myC#Code\myNamespace\myClass.cs.
940
The default class name is taken from the XQuery file name.
The location of Saxon .NET on your system. Stylus Studio adds this URL to the
Microsoft Visual Studio 2005 project, allowing the generated C# code for .NET to
compile.
Whether or not you want the resulting .cs file to contain a static void Main(String
[ ] args) method.
Whether or not you want to open the generated code file. If selected, the generated C#
file is opened in whatever application is registered to open .cs files.
Whether or not you want to embed the XQuery source in the generated C# code. This
option is available when using either the Saxon XQuery or DataDirect XQuery
processors.
Note: This option appears only if you are generating XQuery code.
Whether or not you want to either create a new Visual Studio 2005 project or update
an existing one. If a new project is created, it is automatically opened with whatever
application is registered to open .csproj files. The .csproj file contains all the
necessary references to the generated .cs file, as well as all the .dll files that the .cs
file requires.
To run the .cs file, simply press Ctrl+F5 in Visual Studio.
2.
Define at least one scenario for the XQuery document. The scenario must use the
Saxon processor. See Scenario Properties Used for Generating Code for more
information.
3.
4.
5.
Select XQuery > Generate Code > Generate C# Code from the Stylus Studio menu.
The Generate C# Code dialog box appears. (See Figure 433 on page 940.)
6.
Specify the settings you want for the target directory, namespace and class names, and
so on. See C# Code Generation Settings if you need help with this step.
7.
Click OK.
941
Stylus Studio generates C# code for the XQuery. When the code generation is
complete, the resulting file (classname.cs) is opened in a third-party editor if you
chose the Open the generated file option.
942
Chapter 12
The Web services features described in this chapter are available only in Stylus
Studio XML Enterprise Suite.
Using Stylus Studios Web service call composer, you can design, compose, and test a
Web service call without writing any code. Once Stylus Studio composes the Simple
Object Access Protocol (SOAP) request and you have successfully tested it, you can use
the SOAP response returned by the Web service as an XML source wherever you use
XML documents in Stylus Studio.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the Web Service
Call Composer video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
This chapter covers the following topics:
943
Overview
The process of composing a Web service call in Stylus Studio involves the following
steps:
1.
Specify the Web Services Description Language (WSDL) URL associated with the
Web service you want to use. See Obtaining WSDL URLs on page 947.
2.
Select the operation described by the WSDL for which you want Stylus Studio to
compose a SOAP request.
3.
Test the Web service. You can test a Web service call as you composed it, or you can
create a scenario to test the Web service call using parameters of your choosing. See
Testing a Web Service on page 953.
Once you are satisfied with the Web service call, you can optionally
Save the Web service call for later use. See Saving a Web Service Call on page 955.
Create a Web service scenario. See Creating a Web Service Call Scenario on
page 960.
944
From the Stylus Studio menu bar, select File > New > Web Service Call.
Overview
Stylus Studio opens a new document in the Web Service Call Composer.
Type a WSDL address in the WSDL URL field, or use the UDDI button to browse
UDDI registries for published Web services. See Obtaining WSDL URLs on
page 947 for help with this step. (Any WSDL URLs that you have used previously are
displayed in the WSDL URL drop-down list.)
Web service operations for the WSDL you select are displayed in the Operations
field.
3.
Select the Web service operation for which you want to create a SOAP request from
the Operations field.
Parameters for the operation you select are displayed in the Name field; the datatype
for each parameter is displayed in the Type field. The SOAP request is displayed
beneath the fields you use to define the operations parameters.
4.
945
Alternative: You can manually edit the XML in the SOAP request. If you do, the
Value field is updated automatically.
See Modifying a SOAP Request on page 951 for help with this step.
5.
When you have provided values for all of the parameters, click the Send Request
button (
) to test the Web service.
If it is not already open, Stylus Studio opens the Preview window and displays the
SOAP response returned by the Web service, as shown in Figure 435:
946
Optionally, save the Web service call. See Saving a Web Service Call on page 955
for help with this step.
947
The UDDI Registry field displays a list of public UDDI registries. You use the Query field
(obscured by the UDDI Registry drop-down list in the preceding illustration) to specify the
keywords you want to use to search a UDDI registry from this list. For example, if you
are building a weather application, you might type weather in the Query field to search for
weather-related Web services. Keywords are matched against the Web service and
company information available in the UDDI registry, not against the WSDL itself.
Generally speaking, the same search executed against different UDDI registries will yield
different results.
In addition to specifying keywords, the UDDI Browser dialog box allows you to
Specify whether you want to search by Web service (the default) or by provider
948
Web services related to weather, the Stylus Studio UDDI Browser returns the following
results:
When you select a WSDL URL, Stylus Studio displays the operations supported by the
Web service in the Web Service Call Composer. The first operation is selected by default,
and the SOAP request that defines it is displayed in the XML editing area. Web services
can provide multiple operations. See Modifying a SOAP Request on page 951.
If you do not see a suitable WSDL URL in the UDDI registry you searched, modify your
query in the UDDI Browser and try your search again, or search a different UDDI registry.
949
950
2.
In the UDDI Registry field, type the URL of a UDDI registry, or select a UDDI registry
from the drop-down list.
3.
In the Query field, enter the string you want to use to search the selected UDDI
registry for available Web services.
4.
Max Rows the maximum number of results you want displayed in the Results
field.
5.
6.
Select the WSDL that defines the Web service operation for which you want to
compose a SOAP request and click OK.
The UDDI Browser dialog box closes and you are returned to the Web Service Call
Composer.
When you select an operation from the Operations pane, Stylus Studio displays
Parameters associated with that operation, including their datatype and a field in
which you can enter a value for testing purposes.
The XML that describes the SOAP request associated with that operation. You can
edit the SOAP request, but for initial testing you should restrict changes to providing
parameter values, and you can use the parameters Value field for this purpose.
Understanding Parameters
Stylus Studio displays the datatype for SOAP request parameters. It is not possible to
determine all of the details for parameters, however. A zipCode parameter might take the
following:
Stylus Studio User Guide
951
Or it might take only a single value. Sometimes this type of information is provided in the
WSDL itself. In some cases, however, you might have to contact the Web service provider
to obtain this information.
) near the
Stylus Studio displays the WSDL document in its own XML editor, as shown in
Figure 439:
Select the Web service operation for which you want to compose a SOAP request
from the Operations pane.
The SOAP request for the Web service operation appears in the XML editing area.
2.
In the Name field, select a parameter and enter a value for it in the Value field.
3.
Once you have specified values for the SOAP requests parameters, you can test the Web
service. See Testing a Web Service on page 953.
Understand whether or not the Web service provides the type of information you
expect and require
Learn how parameters you might choose to specify in a Web service call scenario
affect the Web service operation
953
See Creating a Web Service Call Scenario on page 960 to learn more about Web service
call scenarios.
Stylus Studio displays the SOAP response in the Preview window as shown in Figure 440:
954
955
956
The saved Web service call can be used as the source document for an XQuery in the
XQuery mapper, as shown in Figure 441:
XQueries composed using a Web service call as a source document return real-time data
from the Web service as a result.
Select File > Save from the Stylus Studio menu bar.
The first time you save a Web service call, the Save As dialog box appears; for
subsequent save operations, Stylus Studio displays the Save dialog box.
2.
Change the default name (Untitled.wscc, for example), and click Save.
957
Example
Consider the following StockQuotesSoap SOAP request defined using the Swan and
Mokashi WSDL:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<tns:GetQuotes xmlns:s0="http://swanandmokashi.com">
<tns:QuoteTicker>prgs</tns:QuoteTicker>
</tns:GetQuotes>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This SOAP request was created using the Stylus Studio Web Service Call Composer, as
described in How to Compose a Web Service Call on page 944.
958
The XQuery created by Stylus Studio for this Web service call looks like this:
declare namespace tns = "http://swanandmokashi.com";
ddtek:wscall(
<ddtek:location
address="http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx"
soapaction="http://swanandmokashi.com/GetQuotes"/>,
<tns:GetQuotes xmlns:tns="http://swanandmokashi.com">
<tns:QuoteTicker/>
</tns:GetQuotes>
)
Create a Web service call as described in How to Compose a Web Service Call on
page 944.
2.
Test the SOAP request by clicking the Preview Result button, and verify that it returns
the results you require.
3.
Click WebServiceCall > Copy XQuery to Clipboard on the Stylus Studio menu.
Stylus Studio creates XQuery based on the SOAP request and copies the XQuery
code to your systems clipboard.
4.
Open a new XQuery document (File > New > XQuery File), and paste the clipboard
contents into the new document.
959
Scenario Names
960
Scenario Names
You specify a name for a Web service call scenario on the Binding tab of the Scenario
Properties dialog box.
Figure 442. Binding Tab of the Web Service Call Scenario Properties Dialog Box
When you create a Web service call scenario, specify a name that makes it easy to
distinguish one scenario from another.
Microsoft .NET
Apache Axis
961
defaults. Others, such as the SOAP action, are taken directly from the WSDL specified in
the Web Service Call Composer.
Note Values you specify on the Binding tab override those in the WSDL displayed in the Web
Description
The server on which the Web service is executed. For example:
http://glkev.webs.innerhost.com/glkev_ws/WeatherFetcher
.asmx.
This value is taken from the current Web service call. Required.
SOAPAction
The SOAP action described by the WSDL you selected for the Web
service call. For example:
http://www.myasptools.com/GetWeather
This value is taken from the current Web service call. Required.
962
user
password
time out
Create a Web service call if you havent already. See How to Compose a Web Service
Call if you need help with this step.
2.
On the General tab, specify a name for the Web service call scenario.
4.
5.
Select the appropriate transport protocol from the Transport drop-down list.
6.
Specify the binding properties you want to associate with this Web service call
scenario.
7.
Click OK.
The Web service call scenario is saved with the name and settings you specified.
963
Select a scenario from the scenario drop-down list at the top of the editor window:
Alternative:
2.
a.
b.
On the General tab, select the scenario you want to run from the Existing preview
scenarios list.
c.
Click OK.
).
964
1.
2.
In the Existing preview scenarios field, click the name of the scenario you want to
clone.
3.
Click Clone.
In the Scenario name field, type the name of the new scenario.
5.
Change any other scenario properties you want to change. See Overview of Scenario
Features on page 960.
6.
Click OK.
If you change your mind and do not want to create the clone, click Delete and then
OK.
965
966
Chapter 13
The Web services features described in this chapter are available only in Stylus
Studio XML Enterprise Suite.
The Stylus Studio WSDL Editor lets you create, review, and modify Web Services
Description Language (WSDL) documents using graphic or text interfaces. A WSDL
document is a document written using XML that describes a Web service.
This chapter covers the following topics:
Stylus Studio displays an untitled WSDL document (untitled1.wsdl, for example) in the
WSDL Editor. (See Figure 445.) WSDL documents in Stylus Studio are saved with a
.wsdl extension.
To learn more about the WSDL Editor, see Using the WSDL Editor on page 969.
Stylus Studio User Guide
967
To begin defining a WSDL, see Working with WSDL Elements on page 978.
2.
In the Open dialog box, enter the URL for the Stylus Studio .wsdl file or the WSDL
document you want to open.
If you are opening a WSDL document that does not use a .wsdl extension, Stylus
Studio prompts you to specify the editor you want to use to open the document.
Note
3.
968
Click OK.
Text pane, which displays the code for the WSDL document.
Properties window, which shows properties for the selected WSDL element.
Definition browser, which allows you to quickly navigate to a specific WSDL element
or embedded XML Schema.
This section covers the following topics:
969
Create your own WSDL documents. You might want to use the WSDL Editor during
the design stage for a new Web service to describe the services the Web service will
expose, the Web services location, and other information.
Examine WSDL documents that describe existing Web services, to see what services
are exposed, the bindings they use, the types of messages used, and so on.
These and other features of the WSDL Editor are described in greater detail in the
following sections.
970
Diagram Pane
The diagram pane contains graphical representations of the elements, attributes, and other
nodes that make up a WSDL document, including elements from any XML Schema
associated with the WSDL.
Text Pane
The text pane appears below the diagram pane. The two panes are separated by a
horizontal splitter, as shown in Figure 447.
971
If you want, you can display WSDL document text and the diagram at the same time,
using the splitter to change the relative size of the text and diagram panes. You use the
splitter controls to hide either the text pane or the diagram pane with single click.
As you edit the document, using either the diagram or text area, Stylus Studio displays
informational messages as changes are being made and when the two views are
synchronized. Text and diagram views are synchronized automatically.
The default font for text is Courier New, but you can change it to whatever font you want
by clicking the Change Font button ( ).
Tip You can control font and other aspects of the text pane, like line numbers, using the Editor
General page of the Options dialog box.
Properties Window
You use the Properties window to set values for WSDL elements.
972
Not all element values can be set using the diagram pane the Binding elements transport
type, for example. You can write the necessary XML by hand in the text pane if you
choose, but it can be easier, faster, and less error-prone to set these values using the dropdown lists for Values fields in the Properties window.
Tip The Properties window is a docking window you can move anywhere on the desktop.
Represents
Description
Service (wsdl:service)
Types (wsdl:types)
Port (wsdl:port)
Message (wsdl:message)
Part (wsdl:part)
portType (wsdl:portType)
973
Represents
Description
Operation (wsdl:operation)
Binding (wsdl:binding)
Input (wsdl:input)
Output (wsdl:output)
Fault (wsdl:fault)
Documentation
(wsdl:documentation)
Nodes can be expanded and collapsed using the plus and minus symbols, respectively, that
appear on the right side of the node. In Figure 446, for example, the Part1 Message Part
has been expanded; the certifyContactRequestMessage Message has not.
974
about symbols for XML Schema elements. See The Types Element to learn more about
using XML Schema in a WSDL.
For all WSDL documents using the WSDL Details page on the Options dialog box.
For the current WSDL document using the Schema Diagram Properties dialog box.
Using the Schema Diagram Properties dialog box overrides the default settings set
using the Options dialog box.
The mechanics of changing display settings are the same, regardless of where you change
them. For each node property, you can choose to
Show the property only if it is not empty (that is, it has not been defined)
975
window, which appears to the left of the Diagram tab, displays all the properties for any
node you select.)
2.
Navigate the Module Settings > WSDL Editor branch and click WSDL Details.
Display the either the Schema Diagram Properties dialog box, or the WSDL Details
page of the Options dialog box.
2.
Tip
3.
976
Click OK.
Displaying Documentation
By default, text associated with documentation elements (wsdl:documentation) is hidden.
You can expand documentation elements in the diagram by clicking the Show
Documentation ( ) button, or by selecting Diagram > Show Documentation from the
Stylus Studio menu. When you do, the text associated with all documentation elements
defined in the WSDL document appears.
Error Detection
Stylus Studio flags any WSDL or XML Schema errors in the text pane lines that contain
errors are identified with a red triangle, and the type and location of the error is displayed
in the status area at the top of the text pane, as shown here:
When you click the error message, Stylus Studio jumps to that part of the WSDL
document containing the error. When you correct one error, information about the next
error detected by Stylus Studio (if any) is displayed in the status area.
Back-Mapping
Stylus Studio supports back-mapping between the text pane and the diagram pane if you
click an element in the diagram, Stylus Studio scrolls the text pane to display the line of
the WSDL document that defines the element you clicked. A blue triangle is displayed to
the left of the exact line of code.
Background Color
Background color is used as another visual cue for information about the WSDL
document or the XML Schema it might contain:
977
A tan, or light brown, color identifies global nodes these are elements that are
defined as children of the WSDL (wsdl:definitions). In Figure 451, the
gryphonWSFault Message is an example of a such a node.
A light yellow background identifies local instances of globally defined types. In
Figure 451, the GryphonWSFault element is a local instance of that type.
To move from node to node in the diagram, press the arrow keys. (A node must
already be selected.)
You can use the scroll bars to explore the diagram; the zoom slider lets you change
the magnification.
Click Go to Definition (
) on the shortcut menu to display a new page that shows
just the type definition.
978
Tip Use this URL to open the Swanand Mokashi StockQuotes WSDL in Stylus Studio.
Types (wsdl:types)
Service (wsdl:service)
Message (wsdl:message)
Binding (wsdl:service)
Documentation (wsdl:documentation)
979
Description
Target Namespace
The target namespace you want to associate with the Web service
described by the WSDL.
2.
Select Diagram > Add > Types from the Stylus Studio menu.
Alternative: Right-click the Definition element and choose Add > Types from the
shortcut menu.
Stylus Studio adds a Service element to the WSDL.
980
Once it is part of the WSDL definition, you work on a Schema element as if it were an
XML Schema in Stylus Studio. For example, you can either define the XML Schemas
elements, attributes, global types, and so on directly in the WSDL, as shown in
Figure 452, or you can use the Schema element to reference existing XML Schemas
(Diagram > Reference Schemas).
Figure 452. XML Schema Editing Features Available for Schema Elements
See Working with XML Schema in Stylus Studio on page 581 for more information about
creating XML Schema elements from scratch. See Referencing External XML Schemas
on page 636 to learn about importing and including existing XML Schemas.
2.
Select Diagram > Add > Schema from the Stylus Studio menu.
Alternative: Right-click the Types element and choose Add > Schema from the
shortcut menu.
Stylus Studio adds a Schema element to the WSDL.
981
2.
Select Diagram > Add > Service from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Add > Service from the
shortcut menu.
Stylus Studio adds a Service element to the WSDL. The default name is Service-0,
but you can change it.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Service name in the Value field in the Properties window.
Alternative: You can change the Service name directly in the WSDL text.
982
Description
Name
Select the Service element for which you want to describe a port.
2.
Select Diagram > Add > Port from the Stylus Studio menu.
Alternative: Right-click the Service element and choose Add > Port from the shortcut
menu.
Stylus Studio adds a Port element to the WSDL. The default name is Port-0, but you
can change it. Port names must be unique within a given Service element.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Port name in the Value field in the Properties window.
Alternative: You can change the Port name directly in the WSDL text.
Stylus Studio User Guide
983
Description
Name
Binding
Address Type
Address
984
1.
2.
Select Diagram > Add > Message from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Add > Message from the
shortcut menu.
Stylus Studio adds a Message element to the WSDL as a child of the Definitions
element. The default name is Message-0, but you can change it. Message names must
be unique within a WSDL document.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Message name in the Value field in the Properties window.
Alternative: You can change the Message name directly in the WSDL text.
Description
Name
Select the Message element whose Part elements you wish to describe.
2.
Select Diagram > Add > Message Part from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Add > Message Part
from the shortcut menu.
985
Stylus Studio adds a Part element to the WSDL as a child of the Message element.
The default name is Part-0, but you can change it. Part names must be unique within
a given Message.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Part name in the Value field in the Properties window.
Alternative: You can change the Part name directly in the WSDL text.
Description
Name
Element
Type
986
2.
Select Diagram > Add > PortType from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Add > PortType from the
shortcut menu.
Stylus Studio adds a PortType element to the WSDL as a child of the Definitions
element. The default name is portType-0, but you can change it. PortType names must
be unique within a WSDL document.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the PortType name in the Value field in the Properties window.
Alternative: You can change the PortType name directly in the WSDL text.
Description
Name
987
A request-response Operation (a user provides a stock quote ticker, and the Web
service returns information about that stock, for example), the Operation would
contain both Input (the stock ticker) and Output (the Web service response) elements.
A solicit-response Operation (the Web service contacts a client, who provides the
requested input), the Operation would contain both Output (the Web service request)
and Input (the client response) elements.
A notification Operation (the Web service emits output, with no response required or
expected), the Operation would have a single Output element.
An optional Fault element can be used for error handling in both request-response and
solicit response Operation models.
988
1.
2.
Select Diagram > Add > Operation from the Stylus Studio menu.
Alternative: Right-click the PortType element and choose Add > Operation from the
shortcut menu.
Stylus Studio adds an Operation element to the WSDL as a child of the PortType
element. The default name is Operation-0, but you can change it. Operation names
are not required to be unique.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Operation name in the Value field in the Properties window.
Alternative: You can change the Operation name directly in the WSDL text.
Description
Name
2.
Select Diagram > Add > Operation from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Add > Operation from
the shortcut menu.
989
Stylus Studio adds a Binding element to the WSDL as a child of the Definitions
element. The default name is Binding-0, but you can change it. Binding names must
be unique within a WSDL document.
2.
Display the Properties window if it is not already open. (View > Properties).
2.
Change the Binding name in the Value field in the Properties window.
Alternative: You can change the Binding name directly in the WSDL text.
Description
Name
Type
Binding Type
Transport
The WSDL binding for the SOAP protocol. The default value is
http://schemas.xmlsoap.org/soap/http. Sets the transport=
attribute for the soap:binding sub-element.
Note: This field is visible only the Binding Type property is set
to soap.
990
Description
Style
The structure for the contents of the SOAP body. Valid values are
document (unstructured) or rpc (Remote Procedure Style). Sets the
style= attribute for the soap:binding sub-element.
Note: This field is visible only the Binding Type property is set
to soap.
Method
The type of HTTP method used by the binding. Valid values are
GET and POST. Sets the verb= attribute for the http:binding subelement.
Note: This field is visible only the Binding Type property is set
to http.
Select the Operation element whose Input element you want to describe.
2.
Select Diagram > Add > Input from the Stylus Studio menu.
Alternative: Right-click the Operation element and choose Add > Input from the
shortcut menu.
Stylus Studio adds an Input element to the WSDL as a child of the Operation element.
The default name is Input, and you cannot change it.
991
Description
Message
Select the Operation element whose Output element you want to describe.
2.
Select Diagram > Add > Output from the Stylus Studio menu.
Alternative: Right-click the Operation element and choose Add > Output from the
shortcut menu.
Stylus Studio adds an Output element to the WSDL as a child of the Operation
element. The default name is Output, and you cannot change it.
992
Name
Description
Message
Select the Operation element whose Fault element you want to describe.
2.
Select Diagram > Add > Fault from the Stylus Studio menu.
Alternative: Right-click the Operation element and choose Add > Fault from the
shortcut menu.
Stylus Studio adds a Fault element to the WSDL as a child of the Operation element.
The default name is Fault, and you cannot change it.
Description
Message
2.
Select Diagram > Add > Documentation from the Stylus Studio menu.
993
Alternative: Right-click the element and choose Add > Documentation from the
shortcut menu.
Stylus Studio adds a Documentation element to the WSDL element you selected in
Step 1. It appears in the Text pane as:
<wsdl:documentation>Documentation goes here</wsdl:documentation>
3.
2.
Select Diagram > Imported Files from the Stylus Studio menu.
Alternative: Right-click the Definitions element and choose Imported Files from the
shortcut menu.
Stylus Studio displays the Imported Files dialog box.
If the WSDL you are editing already has imported WSDL documents (wsdl:import),
they are listed here.
994
Enter a URL for the WSDL document you want to import, or use the more button
( ) to display the Open dialog box, which allows you to navigate your file systems.
5.
Click OK.
The Import Files dialog box closes, and you are returned to the Imported Files dialog
box. The WSDL document you selected appears in the Files imported by the
document list box.
6.
Click the Add button to import another WSDL; otherwise, click OK.
The Imported Files dialog box closes.
All imported XML Schema and WSDL documents are now available in the local WSDL.
995
Example
In this example, we have imported the WSDL my_StockQuotes.wsdl into our local WSDL.
This WSDL is a copy of the Swanand Mokashi StockQuotes.wsdl. When imported, Stylus
Studio creates the following:
<?xml version="1.0"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:auto9="http://swanandmokashi.com">
<wsdl:import namespace="http://swanandmokashi.com"
location="file:///w:/testing/my_StockQuotes.wsdl"/>
</wsdl:definitions>
In addition to the default xmlns:xsd and xmlns:wsdl namespaces created with the
Definitions elements, notice that the xmlns:auto9 namespace has been added.
Now, if we load the imported WSDL and then create a Binding element, we see that the
Type property drop-down list contains several types with the auto9 namespace prefix:
996
2.
Click Print
.
Alternative: Select File > Print from the Stylus Studio menu.
997
Select Diagram > Export Image from the menu, or select Export Image from the
shortcut menu on the diagram pane (right-click).
Stylus Studio displays the Save As dialog box.
998
3.
Select the file format (.jpg or .emf) from the Files of type drop-down list.
4.
Specify a name and location for the file and click the Save button. The default name
is the name of the WSDL document; the default location is the folder in which the
WSDL document has been saved.
Chapter 14
This chapter describes XML pipelines, and how to use the Stylus Studio XML Pipeline
Editor to create, debug, and maintain XML pipelines. It also describes how to generate
Java code you can use to embed XML pipelines in Java applications.
Support for XML pipelines is available only in Stylus Studio XML Enterprise Suite.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the XML Pipeline
Editor video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
This chapter covers the following topics:
999
A code representation (once you generate code for it) for these data sources, nodes,
and pipes
Validates the output of the XQuery using XML Schema and then either
1000
Description
Node
Input
port
Example
1001
Description
Output
port
Pipe
Example
A node is executed only when all its input ports are filled.
A nodes input port is filled either when it contains a default value that is a reference
to a URL or a literal value, or when it is connected to another nodes output port and
this node provides data that is available. Default values are used only if no pipe is
present for that port.
When data is available on a nodes output port, it is provided to the input ports of all
the nodes to which it is connected.
A nodes input port can be filled by 0 or 1 value. If more than one value becomes
available, this is an error and XML pipeline processing aborts.
1002
You build an XML pipeline in the XML Pipeline Editor using simple drag-and-drop
actions to add an XQuery query to an XML pipeline, for example, you can drag an
XQuery file from the Project window and drop it on the XML Pipeline Editor canvas. You
can also use tools from the Toolbox pane to add nodes to your XML Pipeline. The
Properties window allows you to specify settings for the node (default input and output
values, for example).
You can also use the XML Pipeline Editor to
1003
The XML pipeline canvas, on which you compose the operations and the flow of your
XML pipeline and work with the resulting XML pipeline diagram. See Working
with the XML Pipeline Diagram on page 1059 for more information.
The Toolbox pane contains the tools you use to add transformation, flow control, and
data source operations to your XML pipeline. Operations you add using toolbox tools
are not yet tied to an implementation you need to specify them by setting values in
the Properties window. See Adding Nodes to an XML Pipeline on page 1040 for
more information.
The Properties window, which displays information about the operations in your
XML pipeline. Some default values are provided by Stylus Studio; if you create an
operation by dragging a document from the Project window and dropping it on the
canvas, however, some of that documents information is used to specify property
settings for the operation. For example, if you drag and drop an XQuery document in
the XML pipeline, the .xquery file property is based on the documents URL. See
XML Pipeline Node Properties Reference on page 1076 for more information on
properties for individual nodes.
1004
Many of these operations are also available from the XMLPipeline menu and canvas shortcut menu (right-click to display). See Menu Actions on page 1006 for more
information.
Table 125. Toolbar Button Descriptions
Toolbar Button
Description
Execute
Executes the current XML pipeline and displays the results in the
Preview window. Output (error and warning messages, for
example) appear in the Output window.
Select Scenario
Allows you to choose the XML pipeline scenario for execution and
code generation.
Display Scenario
Properties
Show Grid
Shows (or hides) the grid that appears on the XML Pipeline Editor
canvas.
1005
Description
Snap to Grid
Zoom
Save Image
Saves the entire XML Pipeline diagram (not just what is visible on
the canvas) to an image file.
Menu Actions
In addition to the actions you can perform using the toolbar (see XML Pipeline Editor
Toolbar on page 1005), the XMLPipeline menu and canvas short-cut menu provide the
following actions.
Table 126. Menu Action Descriptions
Menu Action
Description
Add Label/Remove
Label
Allows you to add (and remove) labels from the XML pipeline
diagram.
Edges Style
Lets you choose line, orthogonal, or spline styles for the pipes in the
XML pipeline diagram.
Remove Selection
1006
Gather the requirements for the XML pipeline and select a design approach. You need
to understand the XML pipelines desired output, and perhaps which XML
technologies (XQuery or XSLT, for example) need to be used. See Planning an XML
Pipeline on page 1007.
2.
Identify and/or define the source documents and resources required to execute your
XML pipeline.
3.
Create an XML pipeline document. See Getting Started: Creating a New XML
Pipeline on page 1016.
4.
Optionally, set deployment and processor properties. See XML Pipeline Scenarios
on page 1017.
You can do this step any time prior to previewing and debugging the XML pipeline.
Note
5.
Create and specify the XML pipeline nodes. You can create empty nodes and specify
them manually, or you can create them using XQuery, XSLT, XML Schema, and other
documents. See Working with Nodes on page 1040.
6.
7.
Test the XML pipeline. See Testing the XML Pipeline on page 1030.
8.
Once you are satisfied that the XML pipeline is running as it should, you can optionally
generate Java code. See Generating Code for an XML Pipeline on page 1069 for more
information.
1007
Design Approaches
Stylus Studio supports bottom-up and top-down approaches to designing XML pipelines.
The approach you take depends largely on personal preference, but it can also be
influenced by factors such as whether, for example, your XML pipeline will use existing
transformations (like XQuery or XSLT) or you will build them specifically for use in the
XML pipeline.
The following section is intended to give you some ideas for XML pipeline design.
What the desired output is. Is it HTML? XSL-FO? Both? Or will the XML pipeline
return data to a format other than XML?
If the XML pipeline is intended to stand alone, or whether it will be included in other
XML pipelines.
For the purposes of describing bottom-up and top-down design approaches in this section,
imagine that the requirement for our XML pipeline is to reder data in a text file as PDF.
Bottom-Up Design
In a bottom-up design approach, you already have the individual components, or most of
them, that you will link together to form your XML pipeline. If we were using a bottomup design approach to create an XML pipeline for the use case described in Understand
the Requirements on page 1008, we would:
Have an XQuery file that transforms this XML to XSL-FO and performs FO postprocessing to create PDF.
Using a bottom-up design approach, we would then use these source files to build our
XML pipeline using the following steps:
1008
1.
2.
Drag our XQuery document from the File Explorer or Project window and drop it on
the XML pipeline canvas. This would automatically create and specify the XML
pipelines XQuery node for our XML pipeline. Also, because the XQuery was
defined to perform XSL-FO post-processing, Stylus Studio automatically would
create an XSL-FO node in the XML pipeline.
4.
Connect the output port from the ConvertToXML node to the input port of the
XQuery node. This instructs the XML pipeline to use the converted text file (now
XML) as input for the XQuery transformation.
5.
When you use a bottom-up approach, Stylus Studio leverages as much of the existing
information in the documents you use to build the XML pipeline as possible. Depending
on your design environment, you might need to alter the paths specified for input and
output nodes, source documents, and so on, and you will typically have to link the nodes
in your XML pipeline by creating pipes between appropriate output and input nodes.
Top-Down Design
When you use a top-down design approach, you do not have any pre-existing components
XSLT or XQuery documents, for example or they might not be completely specified.
In this situation, you use the XML Pipeline Editor to sketch a design, and then fill in the
details once you have them. Returning to the use case described in Understand the
Requirements on page 1008, we would sketch our XML pipeline by:
1.
2.
Dragging a ConvertToXML icon from the Toolbox pane and dropping it on the
canvas.
3.
Dragging an XQuery icon from the Toolbox pane and dropping it on the canvas.
4.
Dragging an XSL-FO icon from the Toolbox pane and dropping it on the canvas.
5.
Connecting the ConvertToXMLs output port to the input port of the XQuery node.
6.
Connecting the XQuery nodes output port to the input port of the XSL-FO node.
The top-down approach results in a rough outline of placeholder nodes of the desired
XML pipeline an abstract or conceptual representation of the code we want to generate
to perform XML processing. The next steps would be to:
1.
Identify the source document for the ConvertToXML node, and selecting the built-in
Stylus Studio converter to be used to convert that source files data to XML.
1009
Once these documents are created, they can be used to define nodes that represent them
in the XML pipeline. You can do this
Automatically, by dragging and dropping documents onto the placeholder nodes that
represent them
Source documents and data (an XML, or XML data provided by a Web service, for
example)
A flow that identifies the processing stages performed in the XML pipeline (whether
XML output goes directly to an XSLT transformation for processing, or is first
validated using XML Schema, for example)
You also specify values for the input and output ports on these nodes, which determines
the flow of the processing defined in the XML pipeline.
This section reviews the components you can include in an XML pipeline.
Transformations
A transformation is an operation that takes an input, performs an action on it, and returns
an output. Examples of XML transformations include XQuery and XSLT. Transformation
output can be a finished product XSLT that creates an HTML report, for example or
it can be something that is passed along to another operation for additional processing
XQuery that specifies FO post-processing of the XML it generates, or output passed to an
XML Schema for validation, for example.
You can include the following transformations in an XML pipeline in Stylus Studio:
1011
Flow Control
Flow control nodes control the flow of an XML pipeline. For example, you might choose
to use a Stop node to display a message when the XML pipeline encounters an error
condition such as when it requires an XML document fails validation against its XML
Schema.
You can use the following nodes to control the flow of an XML pipeline in Stylus Studio
Stop stops XML pipeline processing, if, for example, generated XML does not
validate against a given XML Schema
Warning displays a warning message in output, but allows XML pipeline processing
to continue
Data Sources
Data source nodes are used to specify the XML data that is to be processed. For example,
your XML pipeline might begin by processing raw XML, or it might require that nonXML data (such as a text file or a relational table) first be converted to XML prior to
additional processing.
You can use the following nodes to specify data sources in an XML pipeline:
ConvertToXML specifies an operation that converts a flat file (CSV, binary, and so
on) or EDI message type to XML.
Pipeline Input specifies an external input to an XML pipeline that includes the XML
pipeline in which this node is defined.
Pipeline Output specifies an external outout to an XML pipeline that includes the
XML pipeline in which this node is defined.
Tip You can also provide a data source by specifying the Default Value property on that
nodes input port. For example, you could specify the URL of an XML document in this
way.
1012
You use the input port to specify the expected source for the node. You can specify a
default value, or you can connect another nodes output port to it with a pipe. For
example, you might specify the input port for an XQuery node using the URL for an
XML document, or as the output from a ConvertToXML node. If a pipe is connected
to an input port, any default value is ignored.
You use the output port to specify what to do with result from the nodes processing.
You can also specify output ports explicitly or implicitly. For example, you might
specify the URL to which you want the output of a node be copied, you might link the
output to a Validate nodes input port, or you might do both.
You specify the flow of an XML pipelines processing by linking one nodes output port
to another nodes input port.
Identifying Resources
When planning your XML pipeline, you should consider the resources you will require in
order to build it. These include
Source documents for any XQuery and XSLT transformations the XML pipeline will
use, XML Schema used for validation, and so on
Data sources, whether an XML document, data converted from a relational database
or flat file to XML, or XML data returned by a Web service, for example
You should pay particular attention to where these resources will be relative to the
finished XML pipeline when it is being run in its production environment. For example,
if you are using a Web service or relational database that requires some type of
authentication, you need to ensure that the finished application that makes use of your
XML pipeline code includes some means of providing authentication. Similarly, you need
to ensure that the paths of source documents, data sources, and output URLs will be
accessible to the finished application, or that your application provides a way to enter this
information at run-time.
1013
Deployment Considerations
When you are finished building and testing your XML pipeline, you will want to generate
the code that executes the XML pipeline so that you can incorporate it in an application
that uses the XML processing it defines.
In order to do this, you need to understand the environment in which the XML pipelines
application will be run and model that environment in Stylus Studio. For example, your
XML pipeline might be required to use a given XML Schema validation engine, or a
specific XQuery or FO processor, so you should plan for these requirements when
designing your XML pipeline.
You choose the processors you want the components in your XML pipeline to use by
specifying the Execution Framework settings on the Deployment page of the Scenario
Properties dialog box.
Tip You can create multiple scenarios for the same XML pipeline and specify different
order.pipeline Requirements
An organization in our enterprise has requested a report listing book orders, like the one
shown in Figure 460. The report must be available in both HTML and PDF formats. The
source for the book order data is an EDIFACT message; inventory information is
contained in a text file.
The report consists of a table that lists the ISBN, title, and quantity of books that have been
ordered from inventory.
1015
When you create an XML pipeline, Stylus Studio displays a new .pipeline document in
the XML Pipeline Editor. The document has a name of untitledn.pipeline, where n is a
unique number.
1016
Change the settings for individual processors within an execution framework. Any
changes you make to settings within an execution framework affect the current
pipeline only, and not the execution frameworks default settings.
Tip Stylus Studio displays information about whether or not it can generate code based on the
1017
A flat file, booksXML.txt, that contains ISBN, title, manufacturer, and release date
information for every book in inventory.
An EDI file, order.edi, that contains title, ISBN, and quantity information for every
book currently on order.
Neither of these files provides data in XML format, so they will have to be converted to
XML. We will use built-in DataDirect XML Converters for this task.
Convert the source file using a built-in DataDirect XML Converter or a user-defined
custom XML conversion, and then drag the resulting document and drop it on the
XML pipeline canvas.
Create the ConvertToXML node in the XML pipeline using the Toolbox, and then
specify the source file and the DataDirect XML Converter or user-defined custom
XML conversion you want to use to convert it to XML.
While both require a similar number of steps, converting a source file can be more
economical as it creates a resource that you can reuse in the XML pipeline, and elswhere
in Stylus Studio. Both procedures are described in the following sections.
1018
2.
3.
4.
Select booksXML.txt.
5.
Select the Open using XML Converter check box at the bottom of the Open dialog
box.
6.
Click Open.
Stylus Studio displays the Select XML Converter dialog box.
7.
Files.
To view the source .txt and .edi files, double-click them in the Project window to
display them in a Stylus Studio editor.
Tip
9.
Change the value in the First row contains field names to Yes.
1019
Click OK.
The booksXML.txt file appears in the Other Documents folder in the Project window.
If you hover the mouse pointer over the file name, you will see the full specification
of the XML Converter URL used to convert it.
11.
12.
Drag the ConvertToXML icon from the Toolbox pane and drop it on the XML
pipeline canvas.
Stylus Studio creates a ConvertToXML node and displays it in the XML pipeline
diagram.
2.
Display the Properties window (View > Properties) if it is not already open.
3.
Display the Project window (View > Project) if it is not already open.
4.
5.
) when it appears.
1020
Click the Read default value from this URL radio button, and then navigate to
examples\pipelines\order\ folder where you installed Stylus Studio and select
booksXML.txt.
Click OK.
The input port on the ConvertToXML Node turns green, indicating that a source
document has been specified as the input.
Next, we need to specify which built-in converter to use to convert booksXML.txt to
XML.
8.
9.
Click the XML Converter URL field in the Properties window; click the more button
( ) when it appears.
Stylus Studio displays the Select XML Converter dialog box.
10.
Tip
12.
Change the value in the First row contains field names to Yes.
13.
Click OK.
The ConvertToXML node representing the conversion of the booksXML.txt file to
XML is now completely specified, except for the output. We will address that in the
section Setting the XQuery Node Data Sources on page 1029.
1021
Select Electronic Data Interchange (EDI) from the Select XML Converter dialog box.
Accept all default values.
Renaming Nodes
When you add a second node of the same type using the Toolbox, Stylus Studio gives the
second node the same name as the first, with a number to make it unique. If you create a
node by dragging a document and dropping it on the canvas, Stylus Studio gives the node
the same name as the file.
Depending on how you created the ConvertToXML nodes in the XML pipeline, they are
named either:
Select the node you want to rename in the XML pipeline diagram.
2.
3.
Tip Node names are displayed as tooltips in the XML pipeline diagram when you hover the
pointer over the node. You can also create labels for the diagram and for nodes within the
diagram. See Labeling on page 1059 for more information.
1022
In the next stage of the process, we will specify the XQuery file that we will use to join
the data from these two files.
1023
from these source documents to nodes in the XML Schema that represents the structure
to which the resulting XML must conform.
If you open createFullOrder.xquery, which is in the pipelines\order folder of the
examples project where you installed Stylus Studio, you can see how this was done. As
shown in Figure 467, createFullOrder.xquery uses variable declarations, $ediOrder and
$allBooks, for the non-XML data sources. DataDirect XML Converters, which are built
in to Stylus Studio X14 XML Enterprise Suite, convert these data sources to XML on-thefly, any time the XQuery (or an XML pipeline that uses the XQuery) is executed. Thus, if
the data in either booksXML.txt and order.edi changes, the report resulting from the XML
pipeline will change, too.
To specify a non-XML data source as an XML source for the XQuery Mapper, you
1.
1024
Click the Add Source Document button at the top of the XQuery Mapper tab.
This displays the Open dialog box.
You select the file you want to open, and then select the Open using XML Converter
check box.
When you click Open, Stylus Studio displays the Select XML Converter dialog box
(see Figure 465), which you use to select the built-in DataDirect XML Converter you
want to use to convert your non-XML file to XML. Note that this is the same
procedure we used to identify the data sources for the XML pipelines two
ConvertToXML nodes.
4.
When you click OK on the Select XML Converter dialog box, Stylus Studio adds it as
a data source in the Add Source Document pane of the XQuery Mapper.
Next, we need to create global variables for the two source documents. This way, the
XQuery code that Stylus Studio generates will use variable declarations instead of
document functions to reference our data sources.
1025
Right click the source document name and select Associate With > Global Variable.
Stylus Studio displays the Associate Schema with Variable dialog box.
Enter the value you want to use for the variable, and click OK.
When a variable is created (allBooks, for example), Stylus Studio creates a
declaration like the following in the XQuery source code:
declare variable $allBooks as document-node() external;
1026
The first two lines contain the variable declarations for booksXML.txt and order.edi, our
two source files. A FLWOR block (For, Let, Where, Order by, Return) matches ISBN
numbers from order.edi with those in books.xml, and when it finds a match, it returns
See Building an XQuery Using the Mapper on page 813 for more information on using
the XQuery Mapper.
1027
Drag the XQuery icon from the Toolbox pane and drop it on the XML pipeline canvas.
Stylus Studio creates an XQuery node and displays it in the XML pipeline diagram.
2.
Display the Properties window (View > Properties) if it is not already open.
3.
Display the Project window (View > Project) if it is not already open.
4.
These input ports are colored green, indicating that each has a default value specified
for it. These default values correspond to the two data sources we specified as source
documents in the XQuery Mapper.
If you drop createFullOrder.xquery directly on the XML pipeline canvas, Stylus
Studio automatically creates the ConvertToXML nodes that represent the data
sources it uses. See An Alternate Way to Create ConvertToXML Nodes on
page 1030.
Tip
5.
1028
Change the XQuery nodes default name, XQuery operator, to Extract full order
information. (See Renaming Nodes on page 1022 if you need help with this step.)
With the pointer over the Get books catalog from txt file ConvertToXML node,
drag and drop the output port on the allBooks input port on the Extract full order
information XQuery node.
Stylus Studio creates a pipe connecting the two nodes, shown in Figure 472.
Repeat this procedure, connecting the output port from the Get order from EDIFACT
node to the ediOrder input port on the Extract full order
information XQuery node.
request ConvertToXML
1029
):
In this case, Stylus Studio displays a message indicating that the XML pipeline, as it is
currently defined, does not have an output. And if we examine our XML pipeline, we see
that this is true processing terminates with the XQuery node, but its output port is empty.
1030
1.
2.
Specify a value for the Copy To URL property (myFullOrderSample.xml, for example).
The output port changes color, indicating that it has a value specified for it.
Stylus Studio User Guide
If we test the XML pipeline again, we can see that the XML pipeline runs to completion.
Stylus Studio displays the Preview window, the Main tab of which displays an execution
log that describes the processing steps executed in the XML pipeline.
1031
If we click the next tab in the Preview window, we can see the XML output by our XML
pipeline in text view. If we click the Preview in Tree button ( ), we can verify that the
XML document is of the structure we expect.
1032
As shown in Figure 475, the XML Publisher createReport.report uses the XML
document resulting from our XML pipeline, myFullOrderSample.xml, as the data source to
design a simple book order report.
The table, and the values in its columns, was created by simply dragging nodes from the
source document tree and dropping them on the XML Publisher canvas. Additional
formatting was specified using XPath expressions (to control row color and quantity
color, for example).
When the report design was complete, we used XML Publisher to generate XQuery and
XSLT code using the Generate Transformation dialog box.
1033
Add createReport.xsl
To add createReport.xsl to the XML pipeline:
1034
1.
Display the Project window (View > Project) if it is not already open.
2.
Drag createReport.xsl from the pipelines/order folder and drop it on the XML
pipeline canvas.
The colored input port indicates that this XSLT node already has a default input and
value defined for it. We will specify our own input value (the XML document created
by the Extract full order information XQuery node).
Stylus Studio uses the file name for the node name when you create the node by
dragging and dropping a document on the XML pipeline canvas.
Tip
Tip
3.
4.
Next, specify a value for the output port (order.html, for example). See Setting a
Value for an Output Port on page 1030 if you need help with this step.
Since we know the XQuery node generates the XML document we require, we can
delete the Copy to URL for its output port. Otherwise, output will continue to be
written to that URL.
1035
Click the Preview in Browser button to see the XML pipeline output rendered in
HTML.
Tip
Add createReport.xquery
All that remains for our XML pipeline definition is to specify the XQuery node that will
transform myFullOrderSample.xml into PDF. For this purpose, we will use the
createReport.xquery generated by the XML Publisher.
To add createReport.xquery to the XML pipeline:
1036
1.
Display the Project window (View > Project) if it is not already open.
2.
Drag createReport.xquery from the pipelines/order folder and drop it on the XML
pipeline canvas.
Stylus Studio may display a warning message, indicating that the processor specified
for the createReport.xquery document differs from that specified for the XML
pipeline.
Stylus Studio User Guide
4.
Figure 479. New XQuery Node with Automatically Created XSL-FO Node
5.
Next, specify a value for the output port (order.pdf, for example) of the XSL-FO
node. See Setting a Value for an Output Port on page 1030 if you need help with
this step.
1037
Test the XML pipeline one last time by clicking the Execute button ( ).
Stylus Studio reopens the Preview, which displays an execution log for the XML
pipelines operations. New statements appear for the new XQuery and XSL-FO
nodes.
It also reopens the Output window, which shows output from the XSLT processor and
the RenderX FO post-processor.
1038
Click the second tab in the Preview window to display the PDF document created by
the nodes we just added to the XML pipeline.
Finishing Up
Now that the XML pipeline has been tested and we have seen that it successfully
generates the order report in both HTML and PDF document formats. we can generate
Java code for the entire XML pipeline. This code could then be incorporated in, say, a Java
application.
See Generating Code for an XML Pipeline on page 1069 for more information on this
topic.
1039
Types of Nodes
Nodes can be grouped into three broad categories:
Transformation
Flow control
Data sources
These categories are described in XML Pipeline Components on page 1010.
1040
This creates a node that is not yet implemented, whose properties you then need to specify
either by typing, or by dragging an external document and dropping it on the node or
one of its Value fields in the Properties window. For example, if you drag the XSLT icon
and drop it on the canvas, you would need to specify values for the input and output nodes,
as well as the URL of the XSLT document you want that node to represent in your XML
pipeline.
Stylus Studio User Guide
1041
Description
Code Generation
Choose
Java only
ConvertFromXML
Java
Java
Pipeline
Java only
Pipeline Input
Java
Java
Java
ConvertToXML
Pipeline Output
Stop
C#
C#
C#
C#
C#
Validate
Java
Warning
Java only
XML Parser
Java only
XML Serializer
Java only
XQuery
Java
C#
C#
1042
Description
Code Generation
XSL-FO
Java only
XSLT
Java
C#
code.
XQuery and XSLT nodes represent XQuery and XSLT documents. XQuery and XSLT
code is executed using the processors specified in the XML pipelines execution
1043
Input Ports
XQuery and XSLT nodes have a single input port by default which you use to specify the
XML input to be transformed. You can specify a default value, or the value can be
dynamic (the output from another node in the XML pipeline, for example).
Additional input ports, like the one on the XQuery node in Figure 483, appear if
Output Ports
XQuery and XSLT nodes have a single output port, used to specify what to do with the
result of the transformation. You can
Use the Copy to URL property to write the output to a file system
Or both
Scenario Properties
An XQuery or XSLT documents default scenario properties are reflected in the XML
pipeline only if you drop the document directly on the canvas. For example, if the default
1044
scenario for your XQuery document specifies RenderX post-processing, Stylus Studio
automatically adds an XSL-FO node to the XML pipeline, connected to the XQuery
nodes output port when you drop it on the canvas to represent the post-processing. If you
drop the document on an existing XQuery node, however, the XSL-FO post-processing
node is not added to the XML pipeline.
Scenario properties treated in this way include
Processors
Post-processing
Validation
Similarly, changes made to default scenario properties are not reflected in the XML
pipeline unless you re-add the document to the XML pipeline by dropping it on the
canvas.
1045
Studio displays the Processor Mismatch dialog box if the documents processor settings
differ from those specified for the XML pipeline.
You can
Use the processor settings specified for the XML pipeline on the Execution
Framework tab of the Scenario Properties dialog box
Change the XQuery or XSLT processor setting for the XML pipeline
Note Stylus Studio checks XQuery and XSLT processor compatibility only. Validation and FO
processing engines are not checked, and are not altered by any actions you take on the
Processor Mismatch dialog box.
XSL-FO Nodes
Note You cannot use an XSL-FO node in an XML Pipeline for which you plan to generate C#
code.
1046
XSL-FO nodes convert their input to PDF using the FO processor specified in the XML
pipelines execution framework. See Specifying an Execution Framework on
page 1017 for more information on this topic.
They are created automatically when an XQuery or XSLT document that specifies postprocessing is dropped directly onto the XML pipeline canvas. You can also create one by
dragging the XSL-FO icon from the s. The only property you can specify for an XSL-FO
node is its name.
Input Port
XSL-FO nodes have a single input port that you use to specify the XML to be converted
to PDF. This node expects XML defined using the FO grammar. You can specify a default
value, or the value can be dynamic (the output from another node in the XML pipeline,
for example). XSL-FO nodes are typically piped to XQuery and XSLT nodes, but they can
be piped to any node that outputs XML using the FO grammar.
Output Ports
XSL-FO nodes have a single output port, used to specify what to do with the result of the
transformation. Typically you use the Copy to URL property to write the output PDF to a
file system, but you could also pipe it to a converter that does something with the PDF, or
to a Pipeline Output node.
code.
1047
Including an XML pipeline refers to the process of inserting one XML pipeline inside
another instead of piping a nodes output to an XQuery or XSLT transformation for
processing, for example, output is piped to the included XML pipeline. That XML
pipeline performs the processes defined by its nodes, and then returns one or more outputs
to a node in the including XML pipeline for subsequent processing.
Example
The getHoldings.pipeline in the pipelines\stocks folder in the examples project
installed with Stylus Studio uses an included XML pipeline, retrieveData.pipeline.
Figure 486 illustrates how an included XML pipeline is represented in the including XML
pipeline.
Included XML pipelines, as any other documents (XQuery and XSLT, for example),
cannot be edited from the including XML pipeline. You must open these documents
separately.
Tip To open and edit an included XML pipeline or any other document, double-click its node.
1048
Define the XML pipeline (XML pipeline A) you want to include in another XML
pipeline (XML pipeline B).
2.
Ensure that you have defined Pipeline Input and Pipeline Output nodes for XML
pipeline A (the XML pipeline to be included in XML pipeline B).
3.
4.
Connect the input and output ports of the Pipeline node representing XML pipeline
A to node ports in XML pipeline B as required.
Validate Nodes
Validate nodes represent an XML Schema document used to validate XML piped to it
from another node.
1049
You can create a Validate node by dragging an XML Schema document (.xsd) and
dropping it directly on the XML pipeline canvas, or you can drop an XML Schema
document on an existing Validate node.
Display the Properties window if it is not already open (View > Properties).
2.
3.
) when it appears.
Use the add button ( ) to display the Open dialog box, which you can then use to
navigate to the XML Schema you want to add to the Validate node.
5.
Input Port
The Validate node has a single input port that you use to specify the XML you want to be
validated by the XML Schemas specified by the Validate nodes XML Schemas property.
You can specify a default value, or the value can be dynamic (the output from another
node in the XML pipeline, for example).
1050
Output Ports
Validate nodes have two output ports, named Output valid and Output invalid, which you
use to direct the flow of the XML pipeline. Typically, the Output valid port is piped to
another transformation in the XML pipeline, while the Output invalid port is piped to a
node like Stop or Warning.
Choose Nodes
Note You cannot use a Choose node in an XML Pipeline for which you plan to generate C#
code.
A Choose node uses XPath expressions to evaluate one or more conditions based on its
input to direct the flow of XML pipeline processing. The Choose node uses XPath 2.0 to
evaulate the XPath expressions defined for it.
Input Ports
The Choose node can have one or more input ports; by default, it has a single input port,
named Input #0. You use the XPath # property to express a true condition that is, a
condition that must be met in order for processing to continue. The Choose node in
retrieveData.pipeline, for example, uses the XPath expression . castable as
xs:double to check whether or not the user ID it is given as its input is numeric.
The initial context node for each XPath # expression is the data input from Input #0. For
additional input ports (Input #1, Input #2, and so on), data is available to the XPath
expression as $var1, $var2, and so on.
1051
The Choose node evaulates XPath#0. If XPath#0 is true, it sends data from Input #0 to
Output #0. If XPath#0 is false, it evaluates XPath#1. If XPath#1 is true, it sends data from
Input #0 to Output #1, and so on. If none of the XPath # expressions is true, the data from
Input #0 is sent to Output no match port.
Display the Properties window if it is not already open (View > Properties).
2.
3.
4.
Output Ports
By default, a Choose node has two output ports:
Output no match, the default else condition, which is enabled if an input evaluates
to false
You can add additional output ports, which you might want to do if you have added an
input port. The output port that corresponds to the true condition always makes the first
input available to its connecting pipe.
Each output port must have a value specified for it. You can
Use the Copy to URL property to write the output to a file system
Pipe the output to another node (for more processing if the condition evaluates to
true, or to a Stop node if the condition evaluates to false, for example)
Or both
1052
Display the Properties window if it is not already open (View > Properties).
2.
3.
1053
The recommended way to specify an XML Converter URL is to select the built-in XML
Converter or user-defined custom XML conversion from the Select XML Converter dialog
box, which you display by clicking the XML Converter URL field, and then clicking the
more button ( ) when it appears.:
The value in the URL field changes when you select an XML Converter. Properties and
their settings (like decode=no in Figure 491) are displayed only if you change a default
value.
1054
Input Port
ConvertToXML and ConvertFromXML nodes have a single input port that you use to
specify the file to be converted to XML (or vice versa). You can specify a default value,
or the value can be dynamic (the output from another node in the XML pipeline, for
example).
Output Ports
ConvertToXML and ConvertFromXML nodes have a single output port, used to specify
what to do with the result of the transformation. You can
Use the Copy to URL property to write the output to a file system
Pipe the output to another node (like an XQuery transformation, for example)
Or both
Stop Nodes
Figure 492, for example, shows a Stop node piped to the Output invalid output port of the
Validate node if the validation using the XML Schema specified in the Validate node
fails, the Stop node aborts XML pipeline processing, and a user-defined error message is
1055
generated. Stop nodes do not have an output port XML pipeline processing ends if it
encounters a Stop node.
Warning Nodes
Note You cannot use a Warning node in an XML Pipeline for which you plan to generate C#
code.
Warning nodes, like the one shown in Figure 493, do have an output port. When
encountered in XML pipeline processing, a Warning node generates the user-defined
error message you give to it and pipes the input it is given through to the next node in the
XML pipeline.
C# code.
XML Parser nodes convert text input to an XML document.
Input Port
XML Parser nodes have a single input port that you use to specify the text to be converted
to XML. You can specify a default value, or the value can be dynamic (the output from
another node in the XML pipeline, for example).
Output Ports
XML Parser nodes have a single output port, used to specify what to do with the result of
the transformation. You can
Use the Copy to URL property to write the output to a file system
Or both
An output must be specified in order for the node to be processed.
1057
generate C# code.
XML Serializer nodes convert an XML document to text. You can use node properties to
specify characteristics of the resulting text file, such as whether or not you want it to
include an XML declaration, and whether or not to use pretty-print to format it.
Input Port
XML Serializer nodes have a single input port that you use to specify the XML to be
converted to text. You can specify a default value, or the value can be dynamic (the output
from another node in the XML pipeline, for example).
Output Ports
XML Serializer nodes have a single output port, used to specify what to do with the result
of the transformation. You can
Use the Copy to URL property to write the output to a file system
Or both
1058
Displaying a Grid
By default, Stylus Studio displays a grid on the canvas to help you place nodes in a
uniform fashion. You can hide the grid by clicking the Show Grid button, or by selecting
XMLPipeline > Show Grid from the menu or Show Grid from the canvas shortcut menu.
Figure 458 shows the XML pipeline canvas with the grid displayed.
Tip Use Snap to Grid to have Stylus Studio place nodes precisely along grid line coordinates.
This feature is available whether or not you display the grid. See Manipulating Nodes
in the Diagram on page 1062 for more information.
Labeling
You can label the XML pipeline diagram and individual nodes. Labeling is a useful way
to provide documentation for an XML pipeline, especially if you plan to print the
diagram.
Tip Open BookLookup.pipeline, in the \pipelines\servlet folder of the examples project
installed with Stylus Studio for an example of labels in an XML pipeline diagram.
For more information, see Labeling XML Pipeline Diagrams on page 1064.
1059
Zoom
You can zoom the XML pipeline diagram in and out using the zoom slider at the top of
the editor (
) drag the slider to the right to increase zoom, drag it to the left
to decrease zoom. Changing zoom affects both the diagram and the grid (if it is
displayed).
The zoom level you select in the XML Pipeline Editor does not affect the size of the nodes
if you save the XML pipeline diagram as an image the default zoom level is always used
for saved images.
For more information, see Saving the XML Pipeline Diagram as an Image on
page 1063.
1060
Edge Style
You can choose from one of three edge styles for the pipes that connect one node to
another:
Table 128. Edge Styles
Term
Example
Line
Orthogonal
Spline
When you change the style, either from the XMLPipeline menu or the toolbar, you change
the style
Stylus Studio User Guide
1061
Of any pipes that are currently selected; this includes the pipes associated with any
selected nodes
Of any pipe you create after selecting the new style
Select the pipe, or the node whose pipes, you want to change.
2.
3.
Select the edge style you want from the drop-down menu.
1062
simplify the XML pipelines layout, perhaps before saving an image of the diagram.
Changing the diagram layout has no effect on the XML pipelines definition.
Table 129. Ways to Manipulate Nodes
Action
Description
Methods
Rotate ports
Rotate (Clockwise or
Counter-clockwise) buttons
on tool bar
Rotate (Clockwise or
Counter-clockwise) on
shortcut menu
Snap-to-grid
bar
on main menu
Snap to Grid on shortcut
menu
1063
Alternatives: Select XMLPipeline > Save as Image from the menu, or select Save as
Image from the shortcut menu (right-click).
Stylus Studio displays the Save As dialog box.
2.
Select the file format (.jpg or .emf) from the Files of type drop-down list.
3.
Specify a name and location for the file and click the Save button. The default name
is the name of the XML pipeline; the default location is the project folder in which
the XML pipeline has been saved.
You can create as many labels for a pipeline as you like. Each node, however, can be
associated with only one label. You cannot format label text.
Tip For XQuery, XSLT, and other nodes that represent files, use the label to describe the
nodes action or role in the XML pipeline, and enter the file name in the Name property.
To create a label:
1.
1064
Select the operation you want to label. If you want to label the entire XML pipeline,
click the canvas.
3.
4.
Press Enter.
Cross-Language Debugging
An important feature of XML pipeline debugging is Stylus Studios support for crosslanguage debugging. Cross-language debugging allows you to set a breakpoint on, say, an
XQuery node, and then step into the source XQuery document on which the node is based,
debug it, and then step back into the XML pipeline. Cross-language debugging is
supported for
XQuery nodes
XSLT nodes
Included pipelines
1065
Java built-in
Microsoft .NET
Select the XML pipeline node on which you wish to set the breakpoint.
2.
1066
1.
Select the XML pipeline node whose breakpoint you wish to remove.
2.
) or press F9.
) or click F5:
When the debugger hits a breakpoint you have set, it displays a pause symbol, like the one
shown in Figure 498.
When debugging is paused, debugging tools (like those that let you step into and over
breakpoints, and toggles for the Watch, Variables, and Call Stack windows) become
active. You cannot edit the XML pipeline or alter its scenario properties during
debugging, or when the debugger is paused.
order.pipeline.
1067
by the presence of the pause symbol on the following XQuery node it has not yet been
processed. The Variables window shows the data retrieved from booksXML.txt.
When you step into another document from the XML Pipeline Editor, Stylus Studio
pauses the debugger on the first instruction in that document. (In XQuery and XSLT, the
pause symbol is a yellow triangle. You can step over the instructions, one-by-one, by
clicking the Step Over button ( ) or pressing F10. You can set breakpoints within this
document, as well.
You need to stop debugging before you can make changes to a document.
When the document you have stepped into has completed processing, you are returned to
the XML pipeline, and you can continue debugging it.
1068
Debugging button (
1069
Code Support
DataDirect XQuery
Java
Saxonica Saxon
Java
C# for .NET
Microsoft .NET
C# for .NET
Java built-in
Java
Note that changing default processor settings for these frameworks can affect Stylus
Studios ability to generate code for the XML pipeline. See Specifying an Execution
Framework for more information.
Choose
Pipeline
Validate
Warning
XML Parser
XML Serializer
XQuery
XSL-FO
See XML Pipeline Node Properties Reference for more information on these and other
node types.
1070
Figure 501. Generate Java Code for XML Pipeline Dialog Box
You use Generate Java Code for XML Pipeline dialog box to specify
The target directory in which you want the Java code created.
c:\temp\myPipelineJavaCode, for example. If the directory you name does not exist,
Stylus Studio creates it when you run the Java Code Generation wizard. The default
is . , which places the generated code in the same directory as the .pipeline file.
Optionally, a package name. If you specify a package name, Stylus Studio uses this
name to create a subfolder in the target directory you specify. If you specify
mypackage as the package name, for example, the generated code is written to
c:\temp\myPipelineJavaCode\mypackage. (Though optional, it is considered good
practice to create a package name.)
The class name. Stylus Studio also uses the class name for the .java file created by
the Java Code Generation wizard. For example, if you provide the name MyClass,
Stylus Studio creates c:\temp\myPipelineJavaCode\mypackage\MyClass.java.
Whether or not you want to add the generated code to the current project.
Whether or not you want to write an execution log file when the Java class runs.
1071
Whether or not you want to generate inline code. Inline code can be run anywhere,
as-is. If you choose not to generate inline code, you must ensure that the XML
Pipeline Java libraries, xmlpipeline. jar, is in your systems classpath.
Whether or not you want to embed the XQuery source in the generated Java code.
This option is available when using either the Saxon XQuery or DataDirect XQuery
processors. This option is available only if the Generate inline code check box is
selected.
Figure 502. Generate C# .NET Code for XML Pipeline Dialog Box
You use Generate C# .NET Code for XML Pipeline dialog box to specify
Optionally, a namespace name. Stylus Studio uses the namespace name to create a
subfolder in the target directory you specify. If you use myNamespace, for example,
the generated code is written to c:\temp\myPipelineC#Code\myNamespace. (Though
optional, it is considered good practice to create a namespace.)
1072
The class name. Stylus Studio uses the class name for the .cs file created by the Code
Generation wizard. For example, if you provide the name myClass, Stylus Studio
creates c:\temp\myPipelineC#Code\myClass.cs. Stylus Studio uses the XML pipeline
name as the default class name.
The location of Saxon .NET on your system. Stylus Studio adds this URL to the
Microsoft Visual Studio 2005 project, allowing the generated C# code for .NET to
compile.
Whether or not you want the resulting .cs file to contain a static void Main(String
[ ] args) method.
The argument for the setExecutionLog method in the generated application. Choices
are Console.out (the default), Console.err, and Quiet. Set to Quiet to turn off the log.
Whether or not you want to open the generated code file.
Whether or not you want to embed the XQuery source in the generated C# code. This
option is available when using either the Saxon XQuery or DataDirect XQuery
processors. This option is available only if the Generate inline code check box is
selected.
Whether or not you want to either create a new Visual Studio 2005 project or update
an existing one. If a new project is created, it is automatically opened with whatever
application is registered to open .csproj files. The .csproj file contains all the
necessary references to the generated .cs file, as well as all the .dll files that the .cs
file requires.
To run the .cs file, simply press Ctrl+F5 in Visual Studio.
Open the XML Pipeline for which you want to generate code.
2.
Select the desired scenario Stylus Studio generates code only for the active
scenario.
b.
Make sure properties on the Execution framework tab are set appropriately. See
Execution Framework and Code Generation for more information.
3.
4.
1073
Alternative: Select XML Pipeline > Generate Code from the Stylus Studio menu.
Stylus Studio displays a dialog box that allows you to specify code generation
settings. There are separate dialog boxes for Java and C# code. The dialog box that
appears is based on the execution framework you selected for the XML pipeline.
See Code Generation Settings if you need help with this step.
5.
Click OK.
Stylus Studio generates code for the XML pipeline. If you generated Java code, the
resulting file (myPipeline.java, for example) is opened in the Stylus Studio Java
Editor.
1074
2.
Remove the existing Stylus Studio project classpaths from the Project Classpath
dialog box (select Project > Set Classpath from the menu).
2.
Generate code again, which causes Stylus Studio to respecify the project classpaths.
2.
1075
DataDirect XML Converters. Licenses for DataDirect XML Converters are purchased
separately from Stylus Studio X14 XML Enterprise Suite.
Similarly, if you use DataDirect XQuery in your XML pipeline, you must acquire
additional licences if you wish to deploy the XML pipeline application.
Write Stylus Studio at [email protected], or call 781.280.4488 for more
information.
1076
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 132. Choose Node Properties
Property
Description
Name
The name you want to appear in the Choose nodes tooltip. Default
value is Choose.
Number of Inputs
The number of input ports you want the Choose node to have.
Number of Choices
XPath #0
1077
Output Port
Each Choose node has at least two output ports Output#0, and Output no match. It will
have other output ports (Output#1, Output#2, and so on) if other choices have been defined
for the Choose node.
Table 133. Choose Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want the output passed. Can be left blank.
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 135. ConvertFromXML Node Properties
1078
Property
Description
Name
Output Port
Table 136. ConvertFromXML Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want the output passed. Can be left blank.
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 138. ConvertToXML Node Properties
Property
Description
Name
1079
Output Port
Table 139. ConvertToXML Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want the output passed. Can be left blank.
Input Port
Table 140. Pipeline Input Port Properties
Property
Description
Name
The name of the Pipeline Input node that is defined in the included
pipeline; not editable.
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 141. Pipeline Node Properties
1080
Property
Description
Name
The name you want to appear in the Pipeline nodes tooltip. Default
value is Include Sub-Pipeline.
.pipeline File
Output Port
Table 142. Pipeline Node Output Port Properties
Property
Description
Name
The name of the Pipeline Output node that is defined in the included
pipeline; not editable.
DataType
Copy to URL
The URL to which you want the output passed. Can be left blank.
Node
Table 143. Pipeline Input Node Properties
Property
Description
Name
The name you want to appear in the Pipeline Input nodes tooltip.
Default value is Pipeline Input.
DataType
Default Value
The literal value or URL for the document or file you want to use as
the included pipelines main input.
Output Port
Table 144. Pipeline Input Output Port Properties
Property
Description
Name
DataType
1081
Input Port
Table 145. Pipeline Output Input Port Properties
Property
Description
Name
DataType
Node
Table 146. Pipeline Output Node Properties
Property
Description
Name
The name you want to appear in the Pipeline Output nodes tooltip.
Default value is Pipeline Output.
Input Port
Table 147. Stop Node Input Port Properties
1082
Property
Description
Name
DataType
Node
Table 148. Stop Node Properties
Property
Description
Name
The name you want to appear in the Stop nodes tooltip. Default
value is Stop.
Message
The message you want written to output with the Stop node is
processed. The default is Error.
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 150. Validate Node Properties
Property
Description
Name
The name you want to appear in the Validate nodes tooltip. Default
value is Validate operator.
XML Schemas
The URL of the XML Schema you want to use to validate the input.
You can specify more than one XML Schema.
1083
Output Port
The Validate node has two output ports one (named Output valid) used to direct input
if the XML Schema validation passes, the other (named Output invalid) used if the input
is invalid.
Table 151. Validate Node Output Port Properties
Property
Description
Name
The name displayed for the Output valid and Output invalid
ports; not editable.
DataType
Copy to URL
Description
Name
DataType
Node
Table 153. Warning Node Properties
1084
Property
Description
Name
The name you want to appear in the Warning nodes tooltip. Default
value is Warning.
Message
The message you want written to output with the Warning node is
processed. The default is Warning.
Output Port
Table 154. Warning Node Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want to copy the output when a warning
condition is encountered.
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 156. XML Parser Node Properties
Property
Description
Name
The name you want to appear in the XML Parser nodes tooltip.
Default value is XML Parser.
1085
Output Port
Table 157. XML Parser Node Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want to copy the output XML parser output.
Description
Name
DataType
Default Value
The default value for the input. Can be blank (this is the default).
Node
Table 159. XML Serializer Node Properties
1086
Property
Description
Name
The name you want to appear in the XML Serializer nodes tooltip.
Default value is XML Serializer.
format-pretty-print
xml-declaration
encoding
The type of encoding you want to specify for the output. The default
is utf-8.
Output Port
Table 160. XML Serializer Node Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want to copy the output XML parser output.
Can be left blank.
Description
Name
Data Type
Default Value
Node
Table 162. XQuery Node Properties
Property
Description
Name
The name you want to appear in the XQuery nodes tooltip. Default
value is XQuery operator.
.xquery file
The URL of the XQuery file you want this node to represent.
DB Connections
1087
Output Port
Table 163. XQuery Node Output Port Properties
Property
Description
Name
DataType
Copy to URL
The URL to which you want to copy the XQuery output. Can be left
blank.
Description
Name
DataType
Default Value
Node
Table 165. XSL-FO Node Properties
1088
Property
Description
Name
The name you want to appear in the XSL-FO nodes tooltip. Default
value is FO operator.
Output Port
Table 166. XSL-FO Node Output Port Properties
Property
Description
Name
DataType
Copy to URL
Description
Name
Default Value
Node
Table 168. XSLT Node Properties
Property
Description
Name
The name you want to appear in the XSLT nodes tooltip. Default
value is XSLT operator.
.xsl file
The URL of the XSLT file you want this node to represent.
Base URL
The URL you want to use to resolve hyperlinks and images in the
output. This value defaults from the XSLT scenario properties if it
was specified.
1089
Output Port
Table 169. XSLT Node Output Port Properties
1090
Property
Description
Name
DataType
Copy to URL
The URL to which you want to copy the XSLT output. Can be left
blank.
Chapter 15
This chapter describes how to use the Stylus Studio XML Publisher to create XSLT or
XQuery code that generates HTML+CSS or XSL-FO reports based on XML data.
Support for XML Publisher is available only in Stylus Studio XML Enterprise
Suite.
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the Introduction to the XML Publisher
video.
A complete list of the videos demonstrating Stylus Studios features is here:
http://www.stylusstudio.com/xml_videos.html.
This chapter covers the following topics:
1091
Note The examples in this chapter rely on the books.xml and videos.xml documents that are
part of the examples project installed with Stylus Studio. These documents are in the
folders, respectively.
You use the XML Publisher to select the data sources for your report, to build and format
the report using the desired data, and to preview a sample report before you generate the
XSLT or XQuery code.
1092
The XML Publisher canvas. You use the canvas to format your report and identify its
contents.
The data sources panel. You use the data sources panel to identify the XML sources
(relational tables and XML documents, for example) you want to include in your
finished report. You select the data you want in your report by dragging the nodes that
represent the data from the data sources panel and dropping them on the XML
Publisher canvas.
The Properties window. You use the Properties window to fine-tune settings that
affect the finished reports format and contents. For example, you can use XPath
expressions to specify formatting based on results returned by the XPath expression
against a given document node.
In addition, Stylus Studio displays the Preview window when you preview a report.
Process Summary
The process of building an XML Publisher report involves the following basic steps:
1.
Create a new XML Publisher report document (File > New > XML Report).
2.
Choose the report format (HTML or PDF). See Choosing a Report Format on
page 1096.
3.
Add the source documents you want to use for the reports content. See Working
with Data Sources on page 1097.
4.
Add the components you want in your report data, as well as formatting constructs
like lists and tables to the XML Publisher canvas. See Adding Data to a Report on
page 1111.
1093
Optionally, format the data you have added to the XML Publisher canvas. See
Formatting Components on page 1136.
6.
Once you are satisfied with the XML Publisher report, you can generate XQuery or XSLT
code for the report, choosing your desired report format (HTML or XSL-FO).
Each of these steps is described in greater detail in the following sections.
Select File > New > XML Report from the Stylus Studio menu.
The XML Report Format dialog box appears.
1094
Select the desired report format (HTML or PDF) and click OK.
An untitled .report document is opened in the XML Publisher.
The canvas represents the reports body, and all of the work you do when building a report
inserting XML data, tables, text and text blocks, and conditional expressions takes
place within the context of the body.
A useful way to think of the body is as the <body> tag in an HTML document everything
that you do on the report canvas would be described between the <body> and </body> tags
) in the
in an HTML document. This metaphor is represented by the Body glyph (
canvas navigation bar at the top of the canvas everything you subsequently add to the
report canvas will be represented as a child of the reports body.
See How Data is Represented on the Canvas on page 1113 and More About the
Navigation Bar on page 1115 for more information.
1095
Specifying a format up front allows Stylus Studio to use format information to expose
format-specific properties like headers and footers for reports in PDF, for example to
help speed and simplify report creation.
1096
XML documents
EDI and flat files like CSV converted to XML using one of the DataDirect XML
Converters
Web services
This section covers the following topics:
1097
You can edit the value in the Namespace field, which can simplify the process of typing
XPath expressions you might use when defining a property. For example, you could
change books to simply b to shorten and simplify XPath expressions. See Example:
Using Context and XPath Sub-Properties to Format Text on page 1133 to learn more
about using XPath expressions when building XML Publisher reports.
Drag a document or file from the Project or File Explorer windows and drop it on the
data sources panel.
Drag a relational database table from the File Explorer window and drop it on the data
sources panel.
Click the Add Data Source button ( )on the data sources panel and use the Open
dialog box to navigate to the desired data source.
You can use multiple data sources for an XML Publisher report.
1098
The red check on the document icon (see Figure 508) indicates a data sources default
status. You can specify any data source you add as the default data source.
To specify the default data source:
1.
In the data sources panel, select the data source you want to specify as the default
(books.xml, in Figure 511, for example).
1099
Choose the element from the XML Schema or DTD you want to use as the root
element
1100
The Choose root element drop-down list displays all the child elements of the XML
Schema or DTD document you selected as a data souce. Select the element you want to
use as the document root and click OK.
1101
Each entry in the Schema field represents an XML Schema or DTD document used as a
data source. To associate it with an XML instance:
1.
2.
Choose the XML document you want to use as the XML instance and click the Open
button.
The Open dialog box closes; the URL for the file you selected appears in the XML
Instance field.
3.
Click OK.
Stylus Studio previews the XML Publisher report, or begins the code generation
process.
Grouping Data
Watch it! You can view a video demonstration of this feature by clicking the
television icon or by clicking this link: watch the XML Publisher data grouping
video.
The ability to group data from one or more data sources is a common requirement for
many reports. For example, given the videos.xml file, you might want to create a list of
actors that shows all the movies in which he or she has starred.
Stylus Studio facilitates grouping using a feature that allows you to create a relationship
between different data sources (between books.xml and catalog.xml, for example), or
between different data islands within the same source (between two nodes in videos.xml,
for example).
This section describes the relationship feature in XML Publisher and how to use it to
perform grouping.
What is a Relationship?
A relationship is a link between two nodes in one or more data sources that allows you to
compare the values of those nodes. For example, in videos.xml, you might want compare
the value of the id attribute of the actor element with the value of actorRef element, and
then perform some action when those values are equal.
1102
Equal
Not equal
Less than
Greater than
The first node you select is used to define the outer loop
The second node you select is used to define the inner loop
Creating a Relationship
Once you have added one or more data sources to the data sources panel, you can create
a relationship between nodes within the same data source, or across data sources.
To create a relationship:
1.
Add the data source(s) you require for your report. See Adding a Data Source on
page 1098 if you need help with this step.
2.
Select the node you want to use to define the outer loop in the XQuery or XSLT that
will be used to create the report.
The Add Relationship button becomes active, as shown here:
1103
By default, Stylus Studio sets the nodes context using the first repeating element in
the selected nodes hierarchy including the selected node itself. In this example, we
selected the id attribute of the actor element, so the actor repeating element is used
to set the context for this loop.
1104
4.
5.
In the Link To field, select the node you want to use to define the inner loop in the
XQuery or XSLT that will be used to create the report. If you defined more than one
data source in Step 1, you can change the data source in the Data Source drop-down
list.
7.
Choose the comparison operator you want to use to define this relationship from the
Operator drop-down list.
8.
Click OK.
The relationship you just defined appears in the data sources pane of the XML
Publisher Editor.
1105
If you expand the relationship node, you see the graphic representation of the join
formed between the actors/actor/id node and the videos/video/actorRef node.
You can now use this relationship as a data source in XML Publisher. See Example
Using a Relationship in a Report on page 1106 for more information.
1106
Click File > New > XML Report to open the XML Publisher Editor.
2.
Drag videos.xml from the VideoCenter folder in the Stylus Studio examples project
and drop it on the data sources panel in the XML Publisher Editor.
Stylus Studio displays a tree representing the videos.xml document.
3.
Expand the actors node by selecting it and pressing the * key on your number pad.
4.
5.
1107
In the Link To field, expand the videos node and select the actorRef repeating
element.
7.
Since we want the loop on the video element (to locate all movies with a matching
actorRef and id), change the value in the Context field to video (also a repeating
element).
1108
Click OK.
The data source defined by the relationship we just created between the actors and
videos nodes appears in the data sources pane.
9.
Drag the newly defined data source from the data sources pane and drop it on the
XML Publisher canvas.
Stylus Studio creates two loops.
If you place the mouse over the outer loop, the tool tip displays the XPath
/result/actors/actor; similarly the XPath for the inner loop is
/result/videos/video[$actor/@id./actorRef].
Now that the context for the loops has been defined, we next need to specify the data
we want to display.
10.
From the data sources panel, drag the videos/video/title element and drop it in the
inner loop.
11.
From the data sources panel, drag the actors/actor element and drop it in the outer
loop. Select Insert Value from the pop-up menu.
When you have finished, your XML Publisher canvas should look like this:
1109
Click the Preview button ( ), and save the file when prompted.
Before formatting, the report looks like this:
Select the .(actor) glyph in the XML Publisher canvas and click the Bold button on
the XML Publisher tool bar. Add a carriage return (press Enter) after the glyph.
14.
Use the space bar to indent the title glyph. Add a carriage return (press Enter) after
the glyph.
15.
1110
Deleting a Relationship
You can delete the relationships you have defined as data sources for XML Publisher
reports just as you would any other data source.
To delete a relationship:
1.
Select the relationship you want to deletein the data sources pane.
2.
Automatically. You can drag a node from the data sources panel and drop it on the
canvas. When you do, Stylus Studio displays a short-cut menu that displays the types
of components you can create based on the node you have selected. For example, if
you select a repeating element, you can create components that loop tables and lists,
for example.
Manually. You can add an empty component to the report using the main menu
(Report > Insert List, for example) or the canvas short-cut menu (right-click on the
canvas), and then populate the component by dragging and dropping nodes from the
data sources panel. Alternatively, you can specify Context and XPath properties in the
Properties window for the component you want to populate.
The benefit of using the automatic method is that Stylus Studio determines the context and
XPath settings required to return the data you have selected. In addition, when you drop
Stylus Studio User Guide
1111
the node on the canvas, Stylus Studio displays on the short-cut menu only those choices
that are applicable to the node you selected from the data sources panel.
For this example, we use books.xml as the reports data source. When we drop the book
repeating element on the canvas, we select Insert Table > Populated Columns from the
short-cut menu. Stylus Studio creates a table with five columns, one for each of the child
nodes in the book repeating element, as shown in Figure 528.
Figure 527. Table Created Automatically Using Repeating Element Child Nodes
1112
The following table summarizes the types of components you can create and
automatically populate with data based on the node type.
Table 170. Components for Repeating and Non-Repeating Nodes
Repeating Nodes
Non-Repeating Nodes
Text
Text
Image
Image
If
If
Repeater
List
See Working with Report Components on page 1118 for information about specific
components.
Example
The context for the table component shown in Figure 528 is the video repeating element
from the videos.xml document. You can see this if you select the table in the canvas and
look at either the
1113
over it. When you do, Stylus Studio displays a tooltip that includes the URL and XPath.
The following table shows the different types of XPath expressions you might see in an
XML Publisher report.
Table 171. Explanation of XPath Expressions in Data Glyphs
Data Glyph
1114
Contains
Description
A full XPath
The Body glyph in the navigation bar represents the reports body. The dark blue means
that the report body the table headings and empty paragraph markers has the editors
focus. In other words, any editing performed now changing the text to italic, or making
the background a different color, for example would affect every object in the report
body.
The plus sign next to the Body glyph indicates that the report body has at least one child.
Our report has two children the table containing video data, and the table containing
book data. If we click the plus sign, Stylus Studio displays a drop-down menu that lists
the children of the report body, and we see the entries for the video and book tables.
1115
The editors focus moves to the book table. Notice the dashed line around the table in
Figure 531.
Notice that the book glyph, which represents the table containing book data, has two
symbols to its right:
The plus sign, which indicates that the table has children. A tables children are its
cells.
The down arrow, which indicates that the table has siblings. In this example, the table
containing video data is the sibling of the current table.
1116
If we now click a cell directly, say, the cell containing author data, notice how the
navigation bar changes:
Figure 532. The Navigation Bar Operates as a Tree Based on Report Context
In this fashion, the navigation bar operates a tree, always showing you the report
component that currently has focus. Components are displayed from the most general to
the most specific. Look at the navigation bar in Figure 532. When the author glyph in the
table is selected, the glyphs in the navigation bar are interpreted this way (from left to
right):
Table 172. Explanation of Example Navigation Bar Tree
Navigation Bar Glyph
Represents
The entire report. Every other component is a child of the body
component.
The book table. The down arrow means that the table has
siblings.
The cells in the book table. The down arrow means that the cell
has siblings the other cells in the table.
The list component built on the author element.
An item in the list component.
The dynamic value of the author element. It is dark blue
because in our example (Figure 532), it is the report component
that currently has focus.
1117
Notice the video table is not represented in the navigation bar. This is because the current
context in the report canvas is owned by the book table. You can quickly change context
in the canvas by either
Using the down arrow on the table glyph (which currently displays book) to select
video
Note Repeater and text block components have their own glyphs.
Types of Components
There are two types of components you can include in an XML Publisher report:
Visual components; these are components that have a visual representation in the
published HTML or XSL-FO report. Examples include tables and lists.
Non-visual components; these are components that do not have a visual representation
in a finished report. Examples include repeaters and ifs.
All components, regardless of type, are represented graphically on the XML Publisher
canvas.
1118
The following table lists all XML Publisher report components and tells you where to find
more information about them.
Table 173. XML Publisher Report Components
Component Name
Component Type
Table
Visual
List
Visual
Text
Visual
Image
Visual
Repeater
Non-visual
If
Non-visual
Tables
A table is a visual component that usually iterates over the data it contains. You typically
create a table when you want your report to display multiple rows with two or more
columns of dynamic data one row for each movie in the videos.xml file, with each row
containing the movies title, its genre, and its rating, for example.
1119
If your data can be displayed in a single column (only movie titles, for example), you
might want to consider using either the list or repeater components. See Lists on
page 1122 and Repeaters on page 1128 for more information.
Creating a Table
The easiest way to create a table in XML Publisher is to drag and drop a repeating
element. When you drop the repeating element on the canvas, Stylus Studio displays a
short-cut menu with an Insert Table choice. You can insert a table with either
Populated Columns Stylus Studio creates a table with one column for each of the
child nodes of the repeating element. The tables context and XPath are set based on
the repeating element used to create it. Each column contains a data value glyph
representing a child node.
Empty Stylus Studio creates table with three empty columns. As with the previous
option, the tables context and XPath are set based on the repeating element used to
create it, but it is up to you to select from the data sources pane the child nodes you
want to include in the table.
You can also create a table manually (Report > Insert > Table, or select Insert Table from
the canvas short-cut menu). When you create a table like this, however, the context and
XPath are not set for you, and it will only contain the number of rows you explicitly create
for it unless you also define the Loop property for a row.
Graphical Representation
Tables, like the one shown in Figure 534, are displayed as a single row with a loop symbol
( ); the loop symbol indicates a repeating row.
Figure 534 shows a table based on the book repeating element in books.xml that was
created using the Populated Columns short-cut menu choice.
Figure 535 shows a table based on the same repeating element, but it was created using
the Default Columns short-cut menu choice.
1120
Finally, Figure 536 shows a table that was created manually using the Report menu.
Notice that it does not have the loop symbol associated with repeating rows.
Sorting
By default, data for dynamic rows is displayed in document order. You can use an XPath
expression in the Loop propertys Sort sub-property to specify a different sort order. The
Loop property appears on the Row tab of the Properties window.
Select the cell before or after which you wish to add a row or column.
2.
Right-click.
Stylus Studio displays a short-cut menu.
Alternative: Click the Report > Table menu.
3.
2.
3.
1121
Lists
A list is visual component that iterates over the data it contains and contains one or more
items. You typically create a list when you want your report to display a list of dynamic
values all the books, by title, in the books.xml document, for example.
Lists are formatted using bullets, but you can choose numeric, alphabetic, and other
symbols like squares and circles. Depending on your needs, you might prefer to use the
repeater or table components for dynamic data. See Repeaters on page 1128 and
Tables on page 1119 for more information.
Creating a List
The easiest way to create a list in XML Publisher is to drag and drop a repeating element.
When you drop the repeating element on the canvas, Stylus Studio displays a short-cut
menu with an Insert List choice. The lists context and XPath are set based on the
repeating element used to create it. You specify the data you want the list to contain by
dragging the appropriate node from the data sources panel and dropping it in the list as
Value.
You can also create a list manually (Report > Insert > List, or select Insert List from the
canvas short-cut menu). When you create a list like this, however, the context and XPath
are not set for you, and it will iterate over the data you specify only if you also define the
Loop context and Xpath properties for an item.
1122
Graphical Representation
As shown in Figure 537, a list is represented as a bounding box drawn with a dashed line
containing a bullet symbol and, usually, a loop symbol ( ). If you created the list
manually, the loop symbol appears only if you specify the Loop propertys Context and
XPath sub-properties for an item.
Sorting
By default, data for dynamic lists is displayed in document order. You can use an XPath
expression in the Loop propertys Sort sub-property to specify a different sort order.
Adding Items
To add items to a list:
1.
Select the item before or after which you wish to add a new item.
2.
Right-click.
Stylus Studio displays a short-cut menu.
Alternative: Click the Report > List menu.
3.
2.
3.
1123
Text
A text component is a block that allows you to create an area for text that can be formatted
independently from the body text in a report. The text component in Figure 538 has been
formatted using a crimson italic font, which differs from the default body text that
precedes and follows it.
Text components and body text have the same properties (Alignment, Font, Color, Size,
and so on).
Click the canvas where you want to insert the text component.
2.
Graphical Representation
In the XML Publisher canvas, a text component is represented, when selected, as a
bounding box drawn with a dashed line. If the text component is not selected, the
bounding box does not appear.
1124
Images
An image is a component that contains a GIF, JPEG, or some other graphic file. You can
place image components within other components (like tables, lists, and repeaters, for
example), or directly on the report body.
Creating an Image
To create an image component:
Note
1.
Click the canvas where you want to insert the image component.
2.
3.
Specify the location of the image file(s). See Specifying an Image Source on
page 1126 for more information.
The location of all image files must be specified relative to the target destination of
the HTML+CSS or XSL-FO. For example, do not specify c:\myFiles\images as a
source directory unless that directory is accessible to the finished report.
Graphical Representation
In the XML Publisher canvas, an image is represented as a small square with a crosshatched pattern. Figure 539 shows an image component that includes some text to its right
(photo of the author).
Images are resolved when you preview the report only if the image files are accessible to
Stylus Studio using the source information you have specified. Unresolved images are
rendered as red Xs, as shown in Figure 540:
1125
A dynamic image is one whose source changes based on the context defined for it. An
example of a dynamic image is the cover art for the movies in the videos.xml document
the image varies based on the video id as determined by the current context.
To specify a dynamic image, you need to define the image components Source propertys
Context and XPath sub-properties:
Context defines the document context for the evaluation of the Source propertys
XPath sub-property. This can be a source document URL, or a variable.
XPath an XPath expression used to evaluate the source document; the context for
the XPath expression is determined by the Context sub-property. This can be any
XPath expression.
When you specify these properties, Stylus Studio displays <dynamic> in the Source
property field.
Note Regardless of whether you are using static or dynamic images, the image source must be
\examples\VideoCenter\images\video\ directory
1126
name of each .gif file is the same as the value of the id attribute of the video repeating
element. We want to create a simple table displaying the movies title and its cover art, as
shown in Figure 542.
Create a table by dragging the video repeating element and dropping it on the canvas.
This establishes the context for the cells in the table, as well as creating a value,
$video, that represent this context.
2.
Drag and drop the title element in the tables first cell (as a value).
3.
4.
Change the image components Context sub-property to $video. The context for
this variable (result/videos/video) was established automatically when we used
the video repeating element to create the table.
b.
1127
Specify the source for the image files change the body components Base URI
property to c:\Program Files\Stylyus Studio\examples\VideoCenter\images
\video\, or wherever you have installed Stylus Studio.
Repeaters
A repeater is a component that iterates over data in a data source based on the context
defined for it. When the report is executed, a new line is added to the report for each new
value. These lines are not formatted in any way, so, depending on your needs, you might
prefer to use the list or table components for repeating data. See Lists on page 1122 and
Tables on page 1119 for more information.
Creating a Repeater
The easiest way to create a repeater in XML Publisher is to drag and drop a repeating
element. When you drop the repeating element on the canvas, Stylus Studio displays a
short-cut menu with an Insert Repeater choice. The repeaters context and XPath are set
based on the repeating element used to create it. You specify the data you want the
repeater to contain by dragging the appropriate node from the data sources panel and
dropping it in the repeater as Value.
You can also create a repeater manually (Report > Insert > Repeater, or select Insert
Repeater from the canvas short-cut menu). When you create a repeater like this, however,
the context and XPath are not set for you, and it will iterate over the data you specify only
if you also define the Loop context and Xpath properties for an item.
Graphical Representation
In the XML Publisher canvas, a repeater is represented as a bounding box drawn with a
dashed line, usually with a loop symbol ( ) on the left side of the bounding box.
Figure 543 shows a repeater based on the title element in videos.xml. It was created by
1.
1128
Dragging the video repeating element on the canvas and selecting Insert Repeater
from the short-cut menu.
Stylus Studio User Guide
The loop symbol is present only if the repeaters Loop property has values specified for
its Context and XPath sub-properties. You can specify these properties manually in the
Properties window, but it is usually easier to create the repeater by dragging a repeating
element, dropping it on the canvas, and choosing Insert Repeater.
Sorting
By default, data for the repeater component is displayed in document order. You can use
an XPath expression in the Loop propertys Sort sub-property to specify a different sort
order.
Ifs
An if is a component that represents a condition (if... then... else...). You can use if
components to control report content. You can insert if components within other
components (within a table cell, for example).
Creating an If
The easiest way to create an if component in XML Publisher is to select Report > Insert
> If from the Stylus Studio menu, or select Insert If from the canvas short-cut menu.
The if components context is established automatically only if you insert within another
component such as a table or list whose context is already set. The if component does
not inherit its context from the body component.
1129
Graphical Representation
In the XML Publisher canvas, an if component is represented as two tabs, true and false,
within a bounding box drawn with a dashed line. Figure 544 shows an empty if
component.
Example
We need to create a report that contains a simple table that lists the title and rating for all
movies in the videos.xml document. In addition, if the movie carries an R rating, we
want to display the R-rated symbol (
) for emphasis. A sample of the report is
1130
1.
Create a table by dragging the video repeating element and dropping it on the canvas.
This establishes the context for the cells in the table.
2.
Drag and drop the title element in the tables first cell (as a value).
4.
Select the if component and click the If tab in the Properties window.
5.
6.
b.
c.
Set the image components Source property to the location of the image we want
to display for R-rated movies (c:\MyProjects\images\r_rating.gif, for
example).
b.
Drag the rating node from the data sources panel and insert it as a value.
1131
Component Properties
Each component in a report the body, tables, lists, repeaters, and so on is associated
with a set of properties that control its formatting and content. The text component has
properties for Color, Font, Size, and so on. The Color property, for example, lets you
select aqua, bisque, blue, and so on. Properties vary based on the component. (See
Properties Reference on page 1154 for a complete list.)
The Properties window consists of one or more tabbed pages. The specific tabs that are
present in the Properties window vary based on the component you have selected in the
report canvas. As shown in Figure 548, the Properties window for the rating element in
the video table includes tabs for the
1132
The context and XPath expression that return the dynamic value of the rating element
Text value
Cell
Column
Row
Table
The order of the tabs in the Properties window reflects the hierarchy of the currently
selected component, from the most specific (the currently selected component) to the
most general (the parent component to which it belongs), left to right. The report body has
Document, Decimal Format, and Text tabs that let you control global formatting
characteristics.
1133
If we look at the properties for the rating element, we can see how this was achieved.
As you can see, Default Color property is specified as <dynamic>. Stylus Studio sets the
Default Color property to this value automatically when you specify
A context for the evaluation of an XPath expression defined in the XPath property.
Here, the context is $video. Stylus Studio created this variable, which represents the
videos.xml document, when we created the table using the video repeating element
from this document.
1134
The XPath Editor dialog box supports Stylus Studios Sense:X auto-completion and text
coloring, which can provide useful prompts as you type your XPath expression.
To display the XPath Editor dialog box:
1.
Click the XPath entry field for the property you want to define.
The text cursor and a more button appear in the field.
1135
Formatting Components
Formatting in XML Publisher works in a fashion similar to that of formatting in many text
and graphical editors you select the item you want to format and then apply a style from
a tool bar, menu, or palette. An item can be
Formatting Numbers
XML Publisher provides special features for formatting decimal numbers. See
Formatting Decimal Numbers on page 1141.
Styles
Styles include font, background and foreground (that is, text) color, size, and alignment.
For a complete list of available styles, see Text Properties on page 1159.
The tool bar, which is located above the XML Publisher canvas
1136
Each of these methods behaves in a similar fashion in that they apply a style to the
currently selected item. The Properties window, however, is slightly different in
addition to applying a stlye, it sets the default for the component that currently has focus.
See Setting Default Properties on page 1140 for more information.
1137
formatting applied to a parent component affects all of its children unless that child has a
default value specified for it.
Consider the following example report, which shows an introductory sentence (body text)
and a list of book titles (list component).
All of the reports components are displayed using the XML Publisher default settings for
the body component, as seen in the toolbar (font is Arial, size is 10, non-bold, non-italic,
no underline, and so on).
1138
If we now click the Bold button on the toolbar, all of the reports text, including the list
component items, is rendered in bold the list component is a child of the body
component, so all formatting done to the body cascades to the list as well.
Figure 557. Using the Bold Tool to Format the Entire Report
Notice that the values in the Properties window have not changed although we have
changed some of the formatting characteristics for the body component, we have not set
any of its default values.
Next, we select just the title value glyph and click the Italic button.
Figure 558. Using the Italic Tool to Format Only Data Values
Notice that the label in the value glyph has been italicized. And when we preview the
report, we see that the text representing each data value (each books title element)
Stylus Studio User Guide
1139
The value glyph has a format state separate from the body, and this state is reflected in
both the glyph (the label is italicized) and the tool bar (when the glyph is selected, the
italic tool in the tool bar s highlighted).
Clearing Formats
You can clear formats you have applied using the Clear Styles button ( ) on the tool bar
or the Report (Report > Text > Clear Styles) or short-cut menus. Format properties are
removed (or cleared) in the same way that they were applied that is, on a componentby-component basis. For example, if the body component text was italic, when you
1140
cleared the formatting the body component text would be returned to its original state.
Clear removes all formatting, regardless of whether or not the XML Publisher report was
last saved.
Note Clearing formats does not affect a components default property settings.
To clear formatting:
1.
2.
Specify the formatting you want to use which character you want to use as the
decimal separator, for example.
2.
Specify the pattern, called a picture string, you want the decimal numbers in your
report to match in order for this format to be applied.
Formatting for decimal numbers is specified for the report body and affects all decimal
numbers in a report for which you have specified a picture string. Formatting applies only
to dynamically generated values the total value of an order, for example and not to any
numbers that you type by hand as body text or in a text component.
1141
Figure 560. Decimal Format Tab in the XML Publisher Properties Window
For example, if you want decimal values to be separated by a comma (,) instead of a period
(.), you would enter a comma in the Value field for the Decimal Separator property.
Default values are used for any properties that you do not specify. See Table 176,
Decimal Format Properties on page 1155 for more information.
In addition to defining the format of the decimal numbers in your reports, the properties
on the Decimal Format tab also affect the values you can use to define your picture string.
For example, the Digit property defines the character that you use to define digits in the
picture string. Its default value is the number character (#). Similarly, the Decimal
Separator property defines the character used to separate decimal values; its default value
is the period character (.). If you want to use values other than these in your picture strings,
you must be sure to specify them on the Decimal Format tab.
1142
picture string, no formatting is applied to the number string and it is rendered in the
finished report as-is.
Values entered for the Format property must conform with the rules described in the
XSLT specification: http://www.w3.org/TR/xslt20/#dt-picture-string.
Example
We are producing reports for consumption by a European audience. This audience is
accustomed to seeing monetary values represented using the period (.) as the grouping
separator (for thousands, for example), and the comma (,) used as the decimal separator.
Thus, for example, a monetary typically displayed in North America as 4,230.95 needs to
be rendered as 4.230,95 for this report.
To satisfy this report requirement:
1.
2.
3.
4.
1143
Next, we need to define the picture string for the decimal number we want to format
using these characters.
5.
In the XML Publisher canvas, select the glyph that represents the decimal number. In
this example, it is the node for book price.
6.
7.
In the Value field for the Format property, specify the following picture string:
#.###,00. The pound sign (#) is the default character used to represent digits in a
picture string; the zeroes after the decimal separator instruct the XML Publisher to
use 00 unless another value is present in the number string, so 82 is represented as
82,00. If we had specified the picture string as #.###,##, no decimal value would
be represented in the report because none was present in the number string, so 82
would be represented as 82,.
Publisher report.
1144
XSLT 1.0
XSLT 2.0
XQuery 1.0
You select the language, as well as a target for the output file, on the Generate
Transformation dialog box:
Sources
As described in Working with Data Sources on page 1097, if you plan on generating
XSLT for your XML Publisher report you must have specified at least one default source.
(Sources are not required for generating XQuery, though it is considered good practice to
specify one.)
Additional Sources
You can specify multiple sources for an XML Publisher report. The first source is
specified in the XSLT/XQuery Scenario Properties dialog box as shown in the following
table.
Table 174. How Additional Source Documents Are Referenced
Language Type
Scenario Property
XSLT
A global parameter:
xsl:param name=input1
XQuery
Main Input
An external variable:
declare variable $input1 as
document-node() external
1145
The expression associated with these variable names is displayed on the Parameter
Values page of the Scenario Properties dialog box, like the one shown for XQuery
scenarios in Figure 564.
As you can also see, Figure 564 shows how data sources specified in XML Publisher are
represented in the XQuery (and XSLT) editor. This XQuery uses three XML sources:
A local copy of books.xml, displayed on the XQuery data sources panel using the
variable name, $input1, with which it is associated
1146
XQuery code references relational data sources using the collection() function:
See Working with Relational Data Sources on page 850 for more information.
Preview the XML Publisher report. If it is satisfactory, continue with this procedure.
2.
Use the Transformation Language field to specify whether you want to use XSLT 1.0,
XSLT 2.0, or XQuery 1.0.
4.
The default URI for the generated XSLT or XQuery code is displayed in the Save Into
field. Unless you specify otherwise, Stylus Studio uses the .report file name for the
.xsl or .xquery file name.
5.
Click OK.
1147
Getting Started
In this part of the procedure, we create a new XML Publisher report and specify a data
source.
To get started:
1.
Select File > New > XML Report from the Stylus Studio menu.
Stylus Studio displays the XML Report Format dialog box.
2.
3.
If the Project window is not already open, open it (View > Project Window).
4.
Drag videos.xml from the VideoCenter folder to the data sources panel in the XML
Publisher Editor.
1148
5.
6.
Drag the video repeating element from the data sources panel and drop it on the XML
Publisher canvas.
7.
Stylus Studio creates a three-column table. At this point, the XML Publisher Editor
should resemble Figure 566:
Although the table currently contains no values, if you mouse over the repeating
glyph at the left of the table ( ) you will see that it references the videos.xml
document and that the current XPath expression evaluates the video repeating element
(/result/videos/video).
8.
Right-click any cell in the table and select Remove Column from the short-cut menu.
9.
10.
Drag the title node and drop it in the first column; select Insert Value from the shortcut menu.
A value glyph with the element name appears in the cell.
11.
Repeat this step with the rating element, dropping it in the second column.
12.
13.
1149
Click Preview ( ).
Stylus Studio creates a three-column table. At this point, your XML Publisher Editor
should resemble this:
Click the Hide docked window button (the small X) to close the Preview window.
This gives us more room to work, and Stylus Studio will automatically display the
Preview window the next time we preview the report.
1150
16.
17.
18.
19.
Next, we want to adjust the width of the first column, so the ratings appear closer to the
title.
20.
21.
Click the Column tab in the Properties window. (If the Properties window is not
displayed, select View > Properties from the Stylus Studio menu.)
22.
23.
Click Preview ( ).
The Preview window displays the changes.
25.
26.
Click the XPath field, and then click the more button (
Stylus Studio displays the XPath Editor dialog box.
).
1151
Notice Stylus Studios Sense:X auto-completion and text coloring as you type.
Click OK.
29.
Next, use the same process to enter this XPath expression for the Bold property:
if (rating = 'R') then 'bold' else ""
30.
Click Preview ( ).
Our report now looks like this:
1152
We want to use XSLT to generate our report, so we do not need to change the values
for Document Type or Transformation Language.
32.
The default name for the .xsl file is based on the .report file name. We change
Untitled1.xsl to myMovieRatings.xsl and click OK.
Stylus Studio opens the generated XSLT in the XSLT Editor, as shown in Figure 572.
1153
If we preview the XSLT, we see the same results as when we previewed the report in
XML Publisher.
Properties Reference
This section contains reference information for the report component properties displayed
in the Properties window. Where appropriate, properties are grouped by component the
section Table Properties on page 1157 has subsections for row and column properties,
for example. The text property is associated with many components, as well as being a
component in its own right. It has its own subsection (Text Properties on page 1159).
This section is organized as follows:
Properties Reference
Body Properties
Body properties affect all other components in an XML Publisher report unless they have
their own format settings specified for them. Body properties are displayed on these tabs
Document, Decimal Format, and Text.
Table 175. Document Properties
Property
Description
Base URL
Background
Description
Zero Digit
The character used as the digit zero. The default is the digit zero (0).
Digit
The character used for a digit in the picture string. The default is
number sign character (#).
Decimal Separator
The character used for the decimal sign. The default is the period
character (.).
Grouping Separator
Pattern Separator
Minus Sign
The character used as the default minus sign. The default is the
hyphen-minus character (-, #x2D).
1155
Description
Percent
Per mille
The character used as a per mille sign. The default is the Unicode
per-mille character (#x2030).
Infinity
The string used to represent infinity. The default value is the string
Infinity.
NaN
The string used to represent the NaN value. The default is the string
NaN (not a number).
1156
Property
Description
Alignment
Aligns body content along left margin, right margin, or in the center.
Default is None.
Font
Sets the font for body contents. If no value is specified, Stylus Studio
uses the font specified in the toolbar.
Size
Sets the font size for body contents. If no value is specified, Stylus
Studio uses the font size specified in the toolbar.
Color
Sets the font color for body contents. If no value is specified, Stylus
Studio uses the value specified by the Foreground Color tool in the
toolbar.
Background
Bold
Italic
Properties Reference
Table 177. Text Properties
Property
Description
Underline
Base URL
Table Properties
See also:
Description
Component Name
The name of the repeating element on which the table is based. This
name appears in the navigation bar glyph that represents the table.
Editable.
Width
Border
The width of the line used to draw the table border, in points (pt).
CellSpacing
CellPadding
The amount of space between a cell border and its contents, in points
(pt).
Alignment
Aligns cell contents along left border, right border, or in the center.
Default is None.
1157
Row Properties
Table 179. Row Properties
Property
Description
Loop
Sort
Height
Background
The color of the row background. (Set the color of row values using
the Text tab.
Column Properties
Table 180. Column Properties
Property
Description
Width
Background
Cell Properties
Table 181. Cell Properties
1158
Property
Description
Background
Properties Reference
List Properties
See also Item Properties on page 1159.
Table 182. List Properties
Property
Description
Component Name
The name of the repeating element on which the list is based. This
name appears in the navigation bar glyph that represents the list.
Editable.
List Type
The type of symbol or character you want to use for the list: disk (the
default), circle, decimal, lower-alpha, none, square, and upperalpha.
Item Properties
Item properties are the same as Text properties. See Text Properties on page 1159.
Text Properties
Text properties are applicable to text components (Insert > Text) as well as to text in other
components (tables, lists, repeaters, and ifs).
Table 183. Text Properties
Property
Description
Alignment
Aligns text along left margin, right margin, or in the center. Default
is None.
Font
Sets the font for the selected text. If no value is specified, Stylus
Studio uses the font specified in the toolbar.
Size
Sets the font size for the selected text. If no value is specified, Stylus
Studio uses the font size specified in the toolbar.
Color
Sets the font color for the selected text. If no value is specified,
Stylus Studio uses the value specified by the Foreground Color
tool in the toolbar.
1159
Description
Background
Bold
Italic
Underline
Repeater Properties
See also Text Properties on page 1159.
Table 184. Repeater Properties
1160
Property
Description
Loop
Sort
Direction
The way in which the data values that make up the repeaters items
will be added to the report vertical (in a list), or horizontal (in a
row). The default is Vertical.
Properties Reference
If Properties
See also Text Properties on page 1159.
Table 185. If Properties
Property
Description
Condition
Image Properties
Table 186. Image Properties
Property
Description
Width
Height
Source
The location of the image file to be displayed in the report. This can
be an absolute path, or a relative path specified in conjunction with
the Body components Base URL property.
Alignment
Aligns the image relative to the page left, right, or in the center.
Default is None.
Description
Format
1161
1162
Chapter 16
1163
Overview
Stylus Studio can read and write well-formed XML documents (.xml, .xsl, and so on)
from/to TigerLogic XDMS collections. In Stylus Studio, you reference external files
using a URL. The URL used to access TigerLogic XDMS files is
tig://server:port/database_ name/collection_name/file_name.xml:
tig is the prefix that specifies that files will be read from TigerLogic XDMS
server:port is the server name that hosts the TigerLogic XDMS file system; the port is
the port used to connect to the server
database_name is the name of the TigerLogic XDMS database you want to access
collection_name is the name of the TigerLogic XDMS collection associated with the
document you want to open
file_name.xml is the name of the XML document you wish to access within that
collection
For example, to access the auction.xml document in mycollection, you might enter the
following in the URL field of the Stylus Studio Open dialog box:
tig://ntstylus-dev:3408/mydb/mycollection/auction.xml
Note Stylus Studio treats collections very much like directories, and the XML documents
stored within a collection are treated like files within a directory.
You can save files back to the same collection from which they were read, or to some other
file system (your local machine, for example). You can create new collections.
Note You can use a TigerLogic XDMS URL to open an XML document anywhere you can
specify URLs in Stylus Studio. For example, you can use the TigerLogic XDMS URL to
specify the source document for XQuery Mapper and then process the XQuery using the
TigerLogic XDMS XQuery processor.
1164
in a TigerLogic XDMS collection, when you open that document in a subsequent session,
Stylus Studio automatically prompts you for the TigerLogic XDMS connection
information.
1165
Alternative: On the Stylus Studio menu, Click File > Open, and then click the
TigerLogic XDMS icon.
Complete the Server Name, (server address and port; myServer:3008, for example)
User Name, and Password fields, and click OK.
Stylus Studio connects you to the host specified in the Server name field. Icons
representing the host and the TigerLogic XDMS databases residing on that host
appear in the File Explorer window.
3.
Optionally, expand the database folders to view the TigerLogic XDMS collections
stored on that database.
4.
Optionally, expand the collection folders to view the XML documents stored there.
Reconnecting
If you lose your connection with the server hosting the TigerLogic XDMS file system, and
a document from a TigerLogic XDMS collection is open, Stylus Studio displays the
Authentication Required dialog box the next time you try to access that document.
Refresh an XSLT or XQuery that uses an XML document from a TigerLogic XDMS
collection
The Authentication Required dialog box prompts you for the username and password you
used when you first established a connection with the server.
1166
Opening Documents
You can open a document stored in the TigerLogic XDMS file system by dragging it from
the File Explorer window into an open document editor, the document editor tab area, or
some other target. See Dragging and Dropping Files in the Stylus Studio on page 97 and
Using the File Explorer on page 94 for more information. You can also select a
document using the Open dialog box (File > Open).
Saving Documents
When you save a document to the TigerLogic XDMS file system, TigerLogic XDMS first
validates the document to ensure that it is well-formed XML. If the document is wellformed, the document is saved; otherwise, you receive an error from the TigerLogic
XDMS server.
Tip Use the Stylus Studio well-formedness checker
1167
Creating Collections
You can create new TigerLogic XDMS collections in Stylus Studio.
To create a TigerLogic XDMS collection:
1.
2.
Open the File Explorer window if it is not already open (View > File Explorer).
3.
Right-click the TigerLogic XDMS server instance in which you wish to create the
collection.
4.
5.
Alternative:
You can also create a new TigerLogic XDMS collection from the Open dialog box.
1168
1.
2.
Chapter 17
Stylus Studio provides several ways to extend its native functionality. This chapter
describes features that allow you to specify other XML validation engines, and features
that allow you to define and register custom document wizards.
This chapter covers the following topics:
1169
Output for custom validation engines is displayed in Stylus Studios Output Window.
Output for other custom applications, such as that created by the custom document
wizard, is also displayed in Stylus Studios Output Window.
1170
Configure the custom validation engine on the Custom Validation Engines page of
the Options dialog box. This step involves
a.
Providing a name.
b.
c.
d.
Optionally specifying the initial directory, path, and classpath to be used by the
custom validation engine.
Optionally setting a feature that prompts the custom validation engine user for
arguments when the custom validation engine is run.
More information for each of these steps is provided in the following section,
Configuring a Custom Document Wizard on page 1177.
e.
1171
How to display
To display the Custom Validation Engines page:
1.
2.
About macros
Stylus Studio provides macros for some fields to help speed creation of custom validation
engines. Any macro you use to configure the custom validation engine is resolved when
it is run.
Available macros vary based on the field for which they are being used. To display macros
available for a given field, click
. Predefined macros include
${FileDir}
Name
When you click the New button (
)to create a new custom validation engine, Stylus
Studio displays an entry field for the name.
You should replace the default name (Validation Engine 1, for example) with the name
you want to associate with the custom validation engine. The name you enter is displayed
in the drop-down in the XML Editor.
Custom validation engines are displayed in the Validate Document drop-down list in the
order in which they appear here.
You can change the custom validation engine order by
1.
Selecting the custom validation engine whose order in the list you want to change.
2.
Clicking the up or down arrow to the right of the custom validation engine list box as
needed.
1173
Command
You use the Command field to specify the command line used to invoke the custom
validation engine. This is typically the path to the .exe, .cmd, or .bat file that starts the
application.
Arguments
You use the Arguments field to specify any arguments required by the custom validation
engine. Click
to browse predefined macros.
Initial Directory
You use the Initial directory field to specify the directory you want Stylus Studio to use as
the current directory when the custom validation engine is run. Click
to browse
predefined macros.
Path
You use the Path field to define paths to any files (such as .exe and .dll) required by the
custom validation engine. You do not have to define any paths that are already defined in
your PATH environment variable. Separate multiple paths with a semicolon. Click
to
browse predefined macros.
Classpath
You use the Classpath field to define paths to any JVM files required by the custom
validation engine (such as .jar and .class). You do not have to define any paths that are
to browse predefined
already defined in your PATH environment variable. Click
macros.
Prompt for arguments
The Prompt for arguments feature displays a dialog box when the custom validation
engine is run.
1174
The Arguments field allows the user to change the command line and arguments
configured with the custom validation engine when it was registered with Stylus Studio.
Display the Custom Validation Engines page of the Options dialog box. See How to
display on page 1172 if you need help with this step.
2.
Click the New button and enter a name for the custom validation engine. Remember
that this value is displayed in the Validate Document drop-down list in the XML
Editor.
3.
Specify the command line any required arguments. See Command on page 1174
and Arguments on page 1174 if you need help with this step.
4.
5.
Click Prompt for arguments if you want Stylus Studio to display a dialog box that
allows the user to change the command line or arguments when the custom validation
engine is run.
6.
Click OK.
1175
Arguments defined in
Stylus Studio
Values entered by
custom document
wizard users
This document wizard was created using the custom document wizard feature.
1176
Make the necessary third-party software available to Stylus Studio. For example, any
.jar or .exe files associated with the document conversion or generation tool must be
accessible from the Stylus Studio installation.
2.
Configure the custom document wizard on the Custom Document Wizards page of
the Options dialog box. This step involves
a.
Providing a name and, optionally, an icon, for the custom document wizard.
b.
c.
d.
Optionally setting a trace feature that displays processing provided by the thirdparty tool.
More information for each of these steps is provided in the following section,
Configuring a Custom Document Wizard on page 1177.
e.
Defining Arguments
1177
This section describes how to display the Custom Document Wizards page and
information about its fields.
How to display
To display the Custom Document Wizards page:
1.
2.
About macros
Stylus Studio provides macros for some fields to help speed creation of custom document
wizards. Available macros vary based on the field for which they are being used. To
display macros available for a given field, click
.
1178
${StylusDir}, which indicates that the path you are specifying is relative to the Stylus
Studio installation directory.
${OutputFile}, which is used to specify the output generated by the document wizard.
This macro is available in the Command field only.
In addition, Stylus Studio creates argument variable macros for any arguments you define
and displays them with other Command field macros.
Name
)to create a new custom document wizard, Stylus
When you click the New button (
Studio displays an entry field for the name.
You should replace the default name (DocumentWizard1, for example) with the name you
want to associate with the custom document wizard. The name you enter is
Displayed in the Document Wizards dialog box along with the icon you specify for
the custom document wizard.
Used in the title bar of the dialog box the user sees when running the custom
document wizard.
1179
Document type
The Document type field displays a drop-down list of available document types when you
click it:
The document type is the type of output generated by the custom document wizard (XML
Schema, XQuery, and so on). The value you select determines
The tab in the Document Wizards dialog box on which the custom document wizard
is displayed (XML Editor, XSLT Editor, or Java, for example)
The editor Stylus Studio uses to display the output generated by the document wizard
Icon bitmap
You use the Icon bitmap field to specify the path for the icon you want to represent the
custom document wizard. This icon, along with the name you give the custom document
wizard, is displayed in the Document Wizards dialog box. Click
to browse for the
file you want to specify or to insert the ${StylusDir} macro.
If you leave the Icon bitmap field blank, Stylus Studio uses the following default icon for
the custom document wizard:
Command line
You use the Command line field to specify a command line template. Stylus Studio uses
this template to compose the command line that invokes the custom document wizard.
Variables, such as ${InputFile}, are used in place of actual arguments. Users specify
argument values when they run the custom document wizard.
Consider the following example:
java -cp my.jar com.exln.stylus.Import ${QuoteChar} ${InputFile} ${OutputFile}
1180
This command line template allows Stylus Studio to start the specified Java class with a
command line that includes the QuoteChar, InputFile, and OutputFile arguments.
Argument variables can appear anywhere in the command. They must be in the form
${name}. For example:
${InputFile}
${OutputFile}
${LoggingOption}
${SomeArgument}
You must specify the ${OutputFile} argument variable in every command line template.
Stylus Studio always generates the name of the file it opens as the value for the
${OutputFile} argument variable.
to display a menu that provides shortcuts
As with the Icon bitmap field, you can click
that help you specify the command line template. This menu lets you
Display the Custom Document Wizard Arguments dialog box, in which you can
specify the command line arguments and their properties. See Defining Arguments
on page 1182 for more information.
Insert argument variable macros for arguments you have already defined.
Initial directory
You use the Initial directory field to specify the directory you want Stylus Studio to use as
the current directory when the custom document wizard is run. Click
to browse for
the file you want to specify or to insert the ${StylusDir} macro.
Path
You use the Path field to define paths to any files required by the custom document
wizard. You do not have to define any paths that are already defined in your PATH
environment variable. Separate multiple paths with a semicolon.
Click
to display a menu that provides shortcuts that help you specify the PATH field.
From this menu you can
1181
Trace execution
If the custom document wizard you are configuring outputs processing information (error
messages, stack traces, and so on), you can use the Trace execution feature to display this
information in the Output Window of the Stylus Studio editor used to display the custom
document wizards generated document.
Defining Arguments
You must define any arguments required by the custom document wizard using the
Custom Document Wizard Arguments dialog box.
Compose the dialog box used to run the custom document wizard. That dialog box
enables users to provide values for the arguments you define.
Create argument variable macros, which you can then use to compose the command
line template. Stylus Studio displays the argument variable macro it creates in the
Command field menu.
Note Every variable used in the command line template must be defined in the Custom
Document Wizard Arguments dialog box.
How to display
There are two ways to display the Custom Document Wizard Arguments dialog box:
Click the Arguments button on the Custom Document Wizard page. Use this
procedure if you want to define arguments before composing the command line
template.
1182
Select Edit Arguments from the Command field menu that is displayed when you
click
. You can use this procedure if you want to define arguments while
composing the command line.
OutputFIle argument
Stylus Studio creates an OutputFile argument for each custom document wizard. You
cannot delete this argument. You can change its order, if necessary, as described in the
following section.
Argument order
By default, the arguments you define in the Custom Document Wizard Arguments dialog
box are displayed to users in the order in which they are created. Arguments are displayed
in a simple two-column grid, with the argument description in the first column, and an
entry field for the argument value in the other. (See Figure 582 for an illustration of a
custom document wizard dialog box.)
Also by default, the OutputFile argument appears first.
You can change the argument order by
1.
2.
Clicking the up or down arrow to the right of the argument list box as needed.
Note Whether or not the argument order defined here has to match the argument order in the
command line template will vary from one custom document wizard to the next
arguments for some applications can be order independent, for example. Generally
speaking, it is good practice for the argument order in the Custom Document Wizard
Arguments dialog box to match that in the command line template.
Argument attributes
You can specify the following attributes for each argument you define:
Name. Stylus Studio uses the value you enter in the Name field to compose the
argument variable macro. This name is not displayed to custom document wizard
users. Required.
Description. The value you enter in the Description field appears in the custom
document wizard dialog box that is displayed to users when they run the wizard. The
description should provide users with adequate information about the arguments
1183
expected value. It can be useful to distinguish input and output arguments, for
example. Required.
Flag. The flag associated with the argument (-v, or simply - or /, for example). When
Stylus Studio composes the command line for the custom document wizard, it uses
the flag value as a prefix to the argument value supplied by the user.
The Flag field must be specified for Boolean arguments.
Note
Type. The arguments data type. Table 188 summarizes valid values for the Type field
and describes possible values for those types
Table 188. Type Field Values
Type
Description
boolean
1184
InputFile
OutputFile
The custom document wizard user does not specify a value for the
OutputFile argument. Exactly one argument must be of the
OutputFile type. Stylus Studio generates a value for the
OutputFile argument and inserts it in the command line.
string
Default Value. The value used by Stylus Studio for optional arguments, unless another
value is specified by the user when the custom document wizard is run. Default values
Stylus Studio User Guide
for required arguments are ignored Stylus Studio requires users to enter values for
required arguments.
Optional. Whether or not the argument is optional. Valid values for this field are true
or false.
Display the Custom Document Wizard Arguments dialog box. See How to display
on page 1182 if you need help with this step.
2.
4.
5.
If necessary, use the Up and Down arrows to change the argument order. Remember
that the order in which arguments are displayed here is the order in which they appear
in the custom document wizard dialog box when the user runs the wizard.
6.
Click OK.
1185
1186
1.
Display the Custom Document Wizards page of the Options dialog box. See How
to display on page 1178 if you need help with this step.
2.
Click the New button and enter a name for the custom document wizard. Remember
that this value is used as the title for the dialog box displayed to the user when they
run the wizard, as well as for the label associated with the custom document wizard
icon displayed in the Document Wizards dialog box.
3.
Click the Arguments button and define the wizards arguments on the Custom
Document Wizard Arguments dialog box. See Defining Arguments on page 1182
if you need help with this step.
4.
5.
Specify the command line template. See Command line on page 1180 if you need
help with this step.
6.
7.
Click Trace execution if you want to display processing information generated by the
custom document wizard in the Output Window of the Stylus Studio editor window
associated with the custom document wizards Document type.
8.
Click OK.
Chapter 18
Note The material previously in this chapter was deprecated in Stylus Studio 2007 XML
Enterprise Suite Release 2. The functionality provided by the Stylus Studio Java API has
been replaced by DataDirect XML Converters standalone components for Java and
.NET. See the DataDirect XML Converters documentation for more information:
http://www.datadirect.com/techres/xmlconvertersproddoc/index.ssp.
1187
1188
Chapter 19
This section includes topics associated with Stylus Studios context-sensitive help. To
display context-sensitive help within Stylus Studio, press F1.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A
About Stylus Studio XML Enterprise Suite
About Stylus Studio XML Home Edition
About Stylus Studio XML Professional Suite
Add Column
Add Element or Composite Reference
Add References to Schema
Add Segment Reference
Add Table
Assign Shortcut
Associate Schema with Variable
Associate XML Schemas to Project Folder
Associate with XML Instance
Attach to JVM
Authentication Required
B
Backmap Stack
Breakpoints
Build Project From SCC
1189
C
C# Code Generation
Call Stack
Choose Module
Choose Provider
Choose Root Element
Choose Server
Choose Source and Destination Schema
Class Properties
Code Definition
Code List Definition
Composite Definition
Configure External XQuery Processor
Connection Settings
Convert HTML to XML
Convert HTML to XSLT
Custom XML Conversion Editor
Create Java Console
Create Java Servlet
Create Schema or DTD
Create User-Defined Catalog
Create XML Document from DTD
Create XML Document from XML Schema
Custom Document Wizard Arguments
Customize Toolbars
1190
D
DataDirect XQuery Options
Default Value
Description
Diagram Properties Schema Details
Diagram Properties WSDL Details
Diff Folders
Document Wizards
DTD Schema Editor Text Tab
DTD Schema Editor Tree Tab
DTD to XML Schema (Trang)
E
EDI Document Pane
EDI Structure Tree
EDI to XML Editor
Element Definition
F
File Explorer
Find
Find (Mapper)
G
Generate C# .NET Code for XML Pipeline
Generate Java Code for XML Pipeline
Generate Transformation
Generate XML Schema from EDI Standards
1191
I
Illegal Character Found
Import File
Imported Files
Imported Modules
J
Java Class Browser
Java Code Generation
Java Editor
K
Keyboard Accelerators
L
Lookup List
M
Message Definition
N
Name
Named Template
1192
Named/Matched Template
New Custom XML Conversion Definition
New EDI to XML Conversion
New Function
Notes
O
Open and Save As
Options
Options - Application Settings
Options General Back-mapping
Options General Components XML Converters for Java
Options General Components XML Converters for .NET
Options General Components DataDirect XQuery
Options - General - Custom Document Wizards
Options - General - Custom Tools
Options - General - Custom Validation Engines
Options - General - Editor Format
Options - General - Editor General
Options - General - Editor Sense:X
Options - General - File Types
Options - General - Java Virtual Machine
Options General Spell Checking
Options - Module Settings - EDI to XML - EDI Viewer Settings
Options - Module Settings - Java - Debugger
Options - Module Settings - WSDL Editor - WSDL Details
Options - Module Settings - XML Diff - Engine
1193
P
Personal Dictionary Editor
Preview Window
Processor Mismatch
Processor Settings (XQuery)
Processor Settings (XSLT)
Project Window
Project Wizards
Properties for Custom XML Conversions
Properties for DTD Nodes
Properties for EDI to XML Conversions
Properties for XML Pipelines
Properties for XML Publisher
Properties for XML Schema and WSDL Documents
Proxy Settings
1194
R
Redefine Schema Symbols
Referenced Schemas
Register and Activate Stylus Studio
Rename Column
Replace
S
Saxon XQuery Settings
Saxon XSLT Settings
Scenario Properties Bindings Tab (Web Services)
Scenario Properties for EDI to XML Conversions
Scenario Properties Execution Framework
Scenario Properties General Tab (XQuery)
Scenario Properties General Tab (XSLT)
Scenario Properties Parameter Values Tab (XQuery)
Scenario Properties Parameter Values Tab (XSLT)
Scenario Properties Post-process Tab (XQuery)
Scenario Properties Post-process Tab (XSLT)
Scenario Properties Processor Tab (XQuery)
Scenario Properties Processor Tab (XSLT)
Scenario Properties Profiling Options Tab (XQuery)
Scenario Properties Profiling Options Tab (XSLT)
Scenario Properties Validation Tab (XQuery)
Stylus Studio User Guide
1195
T
Text Catalog to XML Catalog
Toolbox Pane
TigerLogic XDMS Server Login
Type Derivation
U
UDDI Registry Browser
V
Value
Variables
View Sample XML
1196
W
Watch
Watch Video Demos of Stylus Studio Features
Web Service Call Composer
WSDL Editor
X
XML Diff Editor Merged View
XML Diff Editor Split View - Text
XML Diff Editor Split View - Tree
XML Editor Grid Tab
XML Editor Schema Tab
XML Editor Text Tab
XML Editor Tree Tab
XML Pipeline Editor Canvas
XML Pipeline Settings
XML Publisher Canvas
XML Publisher Data Sources Panel
XML Publisher Namespaces Pane
XML Report Format
XML Schema Editor Diagram Tab
XML Schema Editor Documentation Tab
XML Schema Editor Tree Tab
XPath Editor
XPath Query Editor
XPath for xsl: Elements
XQuery Editor
1197
1198
Fields
Framework version
Version number and related information for the Java Virtual Machine that Stylus
Studio detected on your system.
Visit Our Home Page
The URL for the Stylus Studio Developer Network (SSDN), Stylus Studios online
forum and resource for XML developers.
Button
Activation and Registration
You use this button to activate or register your copy of Stylus Studio. You might need
to do this if, for example, you complete your evaluation of a Stylus Studio trial copy
and then decide to purchase it.
1199
Fields
Framework version
Version number and related information for the Java Virtual Machine that Stylus
Studio detected on your system.
Visit Our Home Page
The URL for the Stylus Studio Developer Network (SSDN), Stylus Studios online
forum and resource for XML developers.
Button
Activation and Registration
You use this button to activate or register your copy of Stylus Studio. You might need
to do this if, for example, you complete your evaluation of a Stylus Studio trial copy
and then decide to purchase it.
1200
Fields
Framework version
Version number and related information for the Java Virtual Machine that Stylus
Studio detected on your system.
Visit Our Home Page
The URL for the Stylus Studio Developer Network (SSDN), Stylus Studios online
forum and resource for XML developers.
Button
Activation and Registration
You use this button to activate or register your copy of Stylus Studio. You might need
to do this if, for example, you complete your evaluation of a Stylus Studio trial copy
and then decide to purchase it.
1201
Add Column
The XML Editor Grid tab is available only in Stylus Studio XML Enterprise Suite
and Stylus Studio XML Professional Suite.
You use the Add Column dialog box to add attribute and element columns to a table in the
Grid tab of the XML Editor. Columns are added to the table after the last column of its
type new attribute columns follow the last attribute column, for example.
Fields
Column name
The name you want to assign to the column; becomes the attribute or element name
in XML.
Default value
1202
Fields
Choose an element or composite
You can choose an existing element or composite from the Choose an element or
composite drop-down list, or create a new one by clicking either the New Element or
New Composite button. Clicking these buttons displays the Element Definition dialog
box or Composite Definition dialog box, respectively.
Modifier
Indicates whether the element or composite reference is used in your customized EDI
structure. For new element or composite references, you can leave this field empty. If
you are modifying an existing element or composite reference because you want to
indicate that it is not used in your customized EDI structure, set Modifier to Not Used
instead of removing it from the EDI structure.
Valid values for this property are Dependent, Must be used, Not recommended, Not
used, Recommended.
Requirement
The number of times the reference can occur within the segment, composite, or other
definition.
Minimum
1203
The references place within the segment, composite, or other definition. This field is
grayed out unless you have set the EDI Structure Loop Sequence Enabled property
to True. Default value if present, has been calculated not to interfere with other
definitions.
1204
Fields
Type of reference
The way in which you want the external XML Schema referenced by the current
XML Schema:
The URL of the external XML Schema referenced by the current XML Schema or
Schema element in a WSDL document. Used to specify the schemaLocation= attribute
of the referencing instruction (xsd:include, for example).
1205
Fields
Choose a segment
The segment you want to use to create the segment reference. Choose an existing
segment from the drop-down list, or create a new segment by clicking the New button.
(Clicking the New Segment button displays the Segment Definition dialog box,
which you use to create the new segment.)
Modifier
Indicates whether the segment reference is used in your customized EDI structure.
For new segment references, you can leave this field empty. If you are modifying an
existing segment reference because you want to indicate that it is not used in your
customized EDI structure, set Modifier to Not Used instead of removing the segment
reference from the EDI structure.
Valid values for this property are Dependent, Must be used, Not recommended, Not
used, Recommended.
Requirement
The number of times the segment reference can appear within a group or message.
Ordinal
The position within the group or message at which the segment reference starts.
1206
1207
Add Table
The XML Editor Grid tab is available only in Stylus Studio XML Enterprise Suite
and Stylus Studio XML Professional Suite.
You use the Add Table dialog box to add a nested table to a table in the Grid tab of the
XML Editor.
Fields
Path to the root
The path to the root. By default, the table you add is created as a child of the current
table.
Row element name
The name you want to use for the row element in the XML.
Number of rows
The number of rows you want to create in the new table. The default is 2.
1208
Assign Shortcut
Assign Shortcut
Use the Assign Shortcut dialog box to specify the keyboard shortcut for performing a
Stylus Studio task. To display the Assign Shortcut dialog box, select Tools > Keyboard
from the Stylus Studio menu bar. In the Select a macro field, click the macro for which
you want to define a shortcut. Click Create Shortcut.
Fields
Press new shortcut key:
Press the key or keys that you want to be the shortcut. For example, Ctrl+E, F7,
Alt+H.
1209
1210
Fields
Schema files
The name of the XML Schema file associated with the current project.
Namespace URI
Buttons
Displays the Open dialog box, which lets you browse for an XML Schema.
Disassociates the selected XML Schema from the project.
Right-click the project folder you want to associate with an XML Schema.
2.
3.
4.
Browse for the XML Schema you want to associate with the project.
5.
Click OK.
The XML Schema you selected appears in the Schema Files field; the namespace
URI defined in that XML Schema appears in the field.
1211
Click OK.
1212
Fields
Schema
The URL of the XML Schema or DTD you selected as a data source.
XML Instance
The URL of the XML instance you want to associate with the XML Schema.
1213
Attach to JVM
To connect Stylus Studio to a JVM that is running in another application, click Attach in
the Stylus Studio tool bar. JVM 1.4.x is required. This is useful for debugging applications
while they are running.
Fields
Host
Specify the name of the host machine for the JVM you want to attach. The default is
localhost.
Port
1214
Authentication Required
Authentication Required
The Authentication Required dialog box appears when you are trying to open a document
on a server to which you previously established a connection, and the connection has been
dropped or lost. This can happen, for example, upon restarting Stylus Studio when the last
document opened was one stored on a remote database. The servers host and port are
displayed by default. You need to provide the username and password required to log in
to that host.
Fields
User Name
The name used to log in to the host displayed at the top of the Authentication
Required dialog box.
Password
1215
Backmap Stack
The Backmap Stack window displays the code stack of XSLT instructions that generated
a particular part of the result document. To display the Backmap Stack window, in the text
or browser view of the Preview window click the output for which you want to see the
XSLT instructions.
You can do this during debugging or after completely applying a stylesheet.
The Backmap Stack window displays one or more XSLT instructions, and flags the line
in the stylesheet that contains the first instruction in the list. To find the location of another
instruction, click that instruction in the Backmap Stack window.
1216
Breakpoints
Breakpoints
In the Stylus Studio tool bar, click Breakpoints
all open files.
Fields
Locations
Lists the file path and line number for each breakpoint in each open file.
Buttons
Remove
Removes the breakpoints from the selected locations. Select the locations where you
want to remove the breakpoints, click Remove, and then click OK.
Remove All
Removes all breakpoints in all open files. Click Remove All and then click OK.
Go To
Closes the Breakpoints dialog box and moves the cursor to the first selected
breakpoint location. Does nothing if no locations are selected.
1217
Fields
Provider to use
Click the down arrow. Stylus Studio displays a list of the source code control
applications you have installed. Click the one that controls the files from which you
want to create a Stylus Studio project.
Recursively import all subprojects
If you want the Stylus Studio project to contain a hierarchy of files, check this box.
User Name
Buttons
Advanced
1218
C# Code Generation
C# Code Generation
The C# Code Generation wizard is available only in Stylus Studio XML Enterprise
Suite.
You use the C# Code Generation dialog box to specify information Stylus Studio will use
to generate C# code for the current XQuery or XSLT. C# files are generated with a .cs
extension.
Fields
Target directory
Stylus Studio uses the namespace name to create a folder in the target directory you
specify. If you use myNamespace, for example, the generated code is written to
c:\temp\myPipelineC#Code\myNamespace. (Though optional, it is considered good
practice to create a namespace.)
Class name
Stylus Studio uses the class name for the .cs file created by the Code Generation
wizard. For example, if you provide the name myClass, Stylus Studio creates
c:\temp\myPipelineC#Code\myClass.cs. Stylus Studio uses the XML pipeline name
as the default class name.
Saxon .NET folder
Allows you to specify the location of Saxon .NET on your system. Stylus Studio adds
this URL to the Microsoft Visual Studio 2005 project, allowing the generated C# code
for .NET to compile.
Create a Main method
Whether or not you want the resulting .cs file to contain a static
[ ] args) method.
void Main(String
Whether or not you want to open the generated code file. If selected, the generated C#
file is opened in whatever application is registered to open .cs files.
1219
Whether or not you want to embed the XQuery source in the generated C# code. This
option is available when using either the Saxon XQuery or DataDirect XQuery
processors.
Note: This option appears only if you are generating XQuery code.
Add the class to a Visual Studio 2005 project
Either creates a new Visual Studio 2005 project or updates an existing one. If a new
project is created, it is automatically opened with whatever application is registered
to open .csproj files. The .csproj file contains all the necessary references to the
generated .cs file, as well as all the .dll files that the .cs file requires.
To run the .cs file, simply press Ctrl+F5 in Visual Studio.
1220
Call Stack
Call Stack
The Call Stack window displays a list of the locations at which processing was suspended.
To display the Call Stack window, click Call Stack
in the Stylus Studio tool bar. This
button is active only when processing is suspended because of a breakpoint.
For Java classes, Stylus Studio displays the class name, function name, parameters, and
line number. For stylesheets, Stylus Studio displays the template name, path for the
stylesheet, and the line number.
When processing is complete, the call stack is empty.
When execution is suspended, you can use the Call Stack window to jump directly to the
Java or XSLT source. Double-click on a stack line to go to that location. A green triangle
appears to indicate this location in the source file.
1221
Choose Module
Stylus Studio displays the Choose Module dialog box when you try to open a file and that
file has a file name extension that Stylus Studio does not recognize.
Fields
Choose a module
Click the Stylus Studio module that you want to use to view your file.
Always use this module for this file type
Click this box when you want Stylus Studio to always use the module you selected to
open files with the same file name extension as the file you are now opening.
1222
Choose Provider
Choose Provider
When you want to put a file under source control, you must specify the source code
control provider you want to use.
To display the Choose Provider dialog box, the file you want to add to source control must
belong to a project. Select the file, and then click Add to Source Control in the Stylus
Studio tool bar.
Fields
Choose the Source Code Control Provider to use:
Click the down-arrow and select an installed source code control provider.
1223
Fields
Choose Root Element
This field displays a list of elements in the DTD or XML Schema. Click the dropdown list, and then click the element that you want to specify as the root element.
Associate With
This field appears only when you add a second DTD or XML Schema to the XQuery
Mapper source. You use it to specify the XML instance that you want to associate
with the DTD or XML Schema.
This field does not appear if the DTD or XML Schema is the first source document
you add to the XQuery Mapper Stylus Studio uses the XML Source document
specified in the Scenario Properties dialog box as the XML instance in this case.
XML Publisher
Using XML Schema or DTD as a Data Source
Adding a Data Source
1224
1225
Choose Server
Use the Choose Server dialog box to connect to a server (WebDAV, FTP, TigerLogic
XDMS, and so on).
Fields
Server Name
Type the name of the host on which the server you want to access resides.
User Name
1226
Fields
Add Source Document
File Path
Absolute path of an XML document whose schema you want to map to another XML
document.
Root Element
If the source schema is a DTD or XML Schema, identify the node that you want to be
the root element.
Set Target Document
File Path
Absolute path of an XML document whose schema you want another XML document
to map to.
Root Element
If the destination schema is a DTD or XML Schema, identify the node that you want
to be the root element.
1227
Fields
WSDL File
The location and name of the WSDL document whose operation(s) you want to represent
in the XQuery Mapper.
Operation Name
The name of the Web services operation you want to represent in the XQuery Mapper.
This field is populated only after you select a WSDL document.
1228
Class Properties
Class Properties
To specify arguments that Stylus Studio uses to run the active Java class, select Java >
Class Properties from the Stylus Studio menu bar. You must have a Java file open in
Stylus Studio for Java to appear in the menu bar.
Fields
Arguments when running class
1229
Code Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Code Definition dialog box to add a code value to a code list or element. The
customized EDI definition resides in the SEF file for your EDI to XML Conversion. You
can create a code with a single value or a range of values.
Fields
Single Code
Use the Value and Description fields in the Single Code group box to create a single
code value and a description. Values are always created in upper case.
Range
Use the Begin and End fields in the Range group box to create a range of code values
AA to AZ, for example. Values are always created in upper case.
1230
Fields
Code List Name
The name you want to give to the code list. Names are always created in upper case.
1231
Composite Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Composite Definition dialog box to add a composite definition to the EDI
structure associated with your EDI to XML Conversion. The composite definition resides
in the SEF file for your EDI to XML Conversion.
Fields
Composite Name
The name you want to give to the composite. Names are always created in upper case.
Description
1232
Fields
Port number
The port number on which you want Stylus Studio to listen for messages from the
external XQuery processor.
1233
Connection Settings
You use the Connection Settings dialog box to specify connectivity settings for a
relational database server.
Fields
Database Type
The type of database to which you want to connect. You can connect to one of the
default relational databases supported by Stylus Studio (Oracle, MS SQL Server,
Informix, and so on).
See Supported Databases for more information about this field.
Driver Classpath
For certain relational databases (MySQL Community Edition and PostgreSQL, for
example), you need to specify the classpath of the driver that supports the relational
database.
Server URL
The servers network location and other information including the server name, the
port through which the connection is established, and other information, such as a
server ID (SID). Stylus Studio displays default information for this field when you
select a database type.
See Using the Server URL Field for more information about this field.
Username
1234
Fields
DTD URL
The URL of the DTD file you want to convert to an XML Schema.
Use a target namespace
Optionally, the URL of the target namespace you want to specify in the XML Schema
created by the document wizard.
1235
Fields
Choose HTML File to Convert to XML
1236
Fields
Choose HTML file to convert
1237
Fields
XML Document
The path of the XML document you want to convert to XML Schema. You can type
the path, or you can use the browse button (
) to navigate computer and network
file systems.
Generated XSD
The path of the XML Schema document you to create. You can type the path, or you
can use the browse button (
) to navigate computer and network file systems.
1238
Fields
Package
Specify the Java package you want the new class to be in.
Class
Specify the name of the new Java class you want the wizard to create.
1239
Fields
Package
Specify the Java package you want the new class to be in.
Class
Specify the name of the new Java class you want the wizard to create.
Content Type
The servlets content type select HTML, XHTML, or XML from the drop-down list.
1240
Create Relationship
Create Relationship
You use the Create Relationship dialog box to specify the nodes from one or more data
sources you want to use to group data, and to choose the operator used to compare the
node values.
Fields
You use the following fields to specify information for the from (Link From) and to (Link
To) data sources from which you are grouping data. You also choose the operator that is
used to compare the node values.
Table 189. Link From and Link To Properties
Field
Link From
Link To
Data Source
Key
Context
Compare
Control used to specify the type of comparison operation you want to perform on the
data source nodes you select. Valid values are:
Equal
Not equal
Less than
Greater than
1241
1242
Fields
Generate XML Schema
Stylus Studio generates an XML Schema based on the content of the current XML
document and associates the schema with that document.
Output File
Use this field to specify or select the location for the new XML Schema document.
Generate DTD
Stylus Studio generates a DTD based on the content of the current XML document.
Click Internal to insert the DTD at the beginning of your XML document.
Click External to place the DTD in a separate file that your XML document
references. If you click External, type a file path for the file that will contain the
schema, or click Browse to navigate to the desired location.
1243
Create your own catalog based on other catalogs and, optionally, add that catalog to
the current project
Fields
Choose catalogs
A list of publicly available catalogs. This list is dynamic as new catalogs become
available, they are displayed by the User Defined Catalog Wizard.
Description
The description of the catalog in the Choose catalogs list box that currently has
focus.
Add to current project
Check this box if you want to add the user-defined catalog you are creating to the
current Stylus Studio project.
Save catalog to
Specifies the name and location of the user-defined catalog you are creating and
adding to the current project. You use this field only if you are adding the user-defined
catalog to the current project.
Buttons
Add catalog to list
Click this button if you want to add another catalog to catalogs displayed in the
Choose catalogs list.
1244
Fields
DTD File
Type or navigate to a DTD from which you want to create an XML document. Click
to display the Open dialog box, where you can select the DTD you want.
Root Element
Allows you to specify the element that you want to be the root element in the new
XML document.
Expand each element only once
Check box that allows you to specify whether or not you want expand each element
only once in the final XML document this results in a smaller XML document file.
1245
element in the XML document is created using the minimum value of the range specified
for that type. For example, if the XML Schema contains a <part> element defined as
type=xs:integer, the <part> element in the resulting XML document appears as
<part>-9223372036854775808</part>.
Fields
Schema File
The XML Schema from which you want to create the XML document.
Schema Root
The element node in the XML Schema you want to use as the XML documents root.
1246
Fields
Name
Specify the name of the argument that would appear in the command line that
executes your application. Required.
Description
Specify some text that indicates the purpose of this argument. When Stylus Studio
generates the dialog box for your custom document wizard, it uses the text you
specify here as the field name that prompts the user to enter a value. The user then
enters a value for this argument. Required.
Flag
This property allows you to specify a string that Stylus Studio uses as a prefix to the
argument value the user specifies. When Stylus Studio generates the command line
for executing your application, it inserts the flag you specify followed by a space
followed by the value that the user specifies for the argument. For example, you might
specify leading punctuation such as a dash (-) or forward slash (/).
The Flag property is required for Boolean arguments. It is optional for arguments of
other data types. When the value of a Boolean argument is true, Stylus Studio inserts
the value of the Flag property in the command line for executing your application.
Type
Specify the data type of the argument. This can be boolean, string, InputFile, or
OutputFile.
1247
Specify a default value for this argument if it is an optional argument. Stylus Studio
uses this default value if the argument is optional and the end-user does not specify a
value. If you specify a default value for an argument that is required, Stylus Studio
ignores the default value. If an end-user does not specify a value for a required
argument, Stylus Studio displays a message that reminds the end-user that the
argument is required.
If the type of an argument is OutputFile, you cannot specify a default value.
Optional
Boolean value that indicates whether this argument is required for this custom
document wizard. When the type of an argument is OutputFile, the value of the
Optional property is always False and you cannot change it. That is, when the type of
an argument is OutputFile, the end-user must specify an argument value.
Buttons
Define a new argument.
Delete the selected argument.
Move the selected argument one place up in the list of arguments. The order of the
arguments here determines the correspondence to the %1, %2, %3, and so on, variables.
Move the selected custom document wizard one place down in the list of custom tools.
1248
Buttons
Preview Result Displays XML output based on current XML conversion settings.
Open File Allows you to open a new file on which you wish to base an XML
conversion.
Reload Input File Allows you to reload the current file in the Custom XML
Conversion Editor.
Toggle Informational Properties Displays information about the physical
characteristics (size, number of rows, and so on) of the file and the current region, row,
and field.
Display Match Symbol Displays symbols at the front of each row to indicate
whether the row matches the pattern associated with the currently selected row, or with
the match pattern defined for some other row.
Highlight Matching Rows Highlights the rows that match the regular expression you
enter in the Match Pattern property; this field acts as a filter rows that match the pattern
you enter are not output as XML.
Toggle Control Characters Toggles the display of control characters in the
document pane.
Toggle Ruler Toggles the display of the ruler in the document pane.
1249
removing spaces Stylus Studio adds for readability. Affects display only.
Toggle Horizontal Grid Lines Toggles the display of horizontal grid lines in the
document pane.
Toggle Vertical Grid Lines Toggles the display of vertical grid lines in the document
pane.
Convert to Fixed-Width Region Converts a line-oriented region to a fixed-width
region.
Convert to Line-Oriented Region Converts a fixed-width region to a line-oriented
region.
Begin Field In This Column In a fixed-width region, allows you define the start of
a new field.
Start New Region Here Defines a new line-oriented, fixed-width, or no-output
region starting at the cursors present location (specified using either the current row or
byte offset).
Join With Previous Region Joins the current region with the previous region in the
file.
Join With Next Region Joins the current region with the next region in the file.
1250
Customize Toolbars
Customize Toolbars
Use this dialog box to hide and show buttons in the tool bar, and determine the look of the
tool bar. Default, Debug, and Edit each control the appearance of a group of buttons. Click
the check boxes to see the buttons that each one controls.
To display the Customize Toolbars dialog box, select Tools > Customize from the Stylus
Studio menu bar.
To add a tool bar to the Stylus Studio tool bar, click New.
After you make some changes that you want to preserve, click OK.
Fields
Show Tooltips determines whether Stylus Studio displays a label when you hover over a
button.
Large Buttons toggles buttons between a large/small size. The default is large.
1251
Fields
Collection URI Resolver Class
Use this field to specify the Java class for the custom collection URI resolver that you
want to register with Stylus Studio.
Module URI Resolver Class
Use this field to specify the Java class for the custom module URI resolver that you
want to register with Stylus Studio.
Document URI Resolver Class
Use this field to specify the Java class for the custom document URI resolver that you
want to register with Stylus Studio.
1252
Default Value
Default Value
XML Pipeline is available only in Stylus Studio XML Enterprise Suite.
You use the Default Value dialog box to specify the default value to use for an XML
pipeline nodes input port. Default values specified here are always overridden if the input
port receives a value from another nodes output port.
Fields
Use this value as the default
Hard-coded default value that will persist across all XML pipeline executions, unless
the default value is overridden by a dynamic value (such as a value provided by
another nodes output port).
Read default value from this URL
1253
Description
The Description dialog box allows you to edit a value in the Properties window.
1254
page.
Example
The following illustrations show how Inline visibility in diagram settings affect the
appearance of the Mode element in the ProductLine complexType.
Hide setting. This is the default setting. (The ProductInfo node is included for context).
1255
displayed:
Fields
Category/Property
The node and, optionally, properties whose inline visibility settings you want to
change.
Inline visibility in diagram
The conditions under which you want to display a property and its values in the XML
Schema diagram. Inline visibility options are:
Hide The property and its value is always hidden. This is the default.
Show The property and its value is always displayed, even if the property does
not have a value.
1256
Show if not empty The property and its value is displayed only if the property
has a value. Properties with a default value (maxOccurs=1, for example) and
properties for which no value has been explicitly set do not appear using this
setting.
Tip If all of a nodes properties have the same show/hide setting (Hide or Show if not empty,
for example), that value is displayed in the Inline Visibility in Diagram field. If no value
is displayed in the Inline Visibility in Diagram field, it means that two or more properties
1257
Example
By default, Name, Binding, Address Type, and Address properties are shown for all port
elements, as shown in the following illustration. Notice that even properties that do not
have a value defined for them are displayed:
1258
set are displayed in the diagram. (In this example, notice that the Address property is no
longer displayed.)
the diagram.
Fields
Category/Property
The node and, optionally, properties whose inline visibility settings you want to
change.
Inline visibility in diagram
The conditions under which you want to display a property and its values in the
WSDL diagram. Inline visibility options are:
Hide The property and its value are always hidden. This is the default for most
elements.
Show The property and its value are always displayed, even if the property does
not have a value.
Show if not empty The property and its value are displayed only if the property
has a value. Properties with a default value (maxOccurs=1, for example) and
properties for which no value has been explicitly set do not appear using this
setting.
Tip If all of a nodes properties have the same show/hide setting (all are set to Hide, for
example), that value is displayed in the Inline Visibility in Diagram field. If no value is
displayed in the Inline Visibility in Diagram field, it means that two or more properties
1259
1260
Diff Folders
Diff Folders
XML Differencing is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
You use the Diff Folders dialog box to select two folders you want to compare using the
Stylus Studio Differencing calculation. You can also use this dialog box to launch a
diffing operation for XML documents you select from the source and target folders.
Fields
Source Folder
Displays the path and name of the folder you select using the Choose Source Folder
button.
Target Folder
Displays the path and name of the folder you select using the Choose Target Folder
button.
Show files of type
Allows you to filter the display of the Source folder and Target folder fields to only
XML documents (files with a .xml extension). This is the default. You can also choose
to display all files in a given directory.
1261
Document Wizards
To access the document wizards, from the Stylus Studio menu bar, select File > Document
Wizards. There are three categories of document wizards:
JSP 1.2/2.0 automatically creates a valid schema for a JSP page in XML format.
User-Defined Catalog lets you create a new catalog based on one or more existing
catalogs and, optionally, save that catalog to the current Stylus Studio project.
EDI to XSD lets you createa XML Schema for any of the numerous EDI dialects and
versions supported by DataDirect XML Converters.
XML Schema to XML generates an XML document from an XML Schema document.
DTD to XML Schema (TRANG) generates a sample XML document from a DTD using
the TRANG processor.
Text Catalog to XML Catalog converts a catalog in OASIS text format to XML format.
1262
Document Wizards
1263
Buttons
Indent XML Tags indents the XML. This action cannot be undone.
Check well-formed checks whether the DTD consists of well-formed XML.
Validate Document validates the DTD using the XML parser you select.
IE Preview displays the document in the Internet Explorer Web browser.
Change Font changes the font of the text display in Stylus Studio. This change affects
only the Stylus Studio display. Beyond personal preference, this is useful for localization.
The fonts that are available are the fonts that can display the characters in your XML file.
Open Schema allows you to open an external DTD, if the DTD has one. This feature
1264
Buttons
Change the font used to display text in the DTD schema editor.
Delete the selected node.
Change the name of the selected node.
Move the selected node up.
Move the selected node down.
1265
Define an attribute name. This attribute is associated with the element that was
selected when you clicked New Attribute.
New Modifier
Click an element node, and then click this button to specify a modifier for the
data or subelements that you want the selected element to contain. You can
specify the following modifiers:
document. If the contained node does appear, there can be only one.
One or more - This contained node is required. There must be at least one
instance, and there can be multiple instances, of this contained node in an
instance document.
Choice - The selected element can contain one of the subelements for
Click a DTD Modifier node (Choice or Sequence) and then click this button to
specify an element that the parent element of the Choice or Sequence node can
contain.
1266
Click a DTD Modifier node, and then click this button to add character data to
the element node.
New Entity
Click the DTD node at the top of the document. Then click New Entity to
define a general entity.
New Parameter Entity
Click the DTD node at the top of the document. Then click New Parameter
Entity to define a parameter entity.
New Text
Click the DTD node at the top of the document. Then click New Text to add
white space between elements, entities, or comments. Click the up arrow to
move the white space.
New Comment
Click the DTD node at the top of the document. Then click New Comment to
add a comment. Use the up arrow to move the comment. It can be between
elements or entities. You cannot insert it among the nodes that define an
element.
1267
Fields
There are two types of fields in the XSD from DTD (Trang) document wizard:
Input fields (displayed in the wizard as [input]) control how the source file will be
interpreted and converted into XML Schema.
Output fields (displayed in the wizard as [output]) control formatting and other
characteristics of the generated XSD file.
Input file (required)
The name and location of the DTD file you want to convert to XSD. You can type the
file name or use the Browse button to browse a file system for the source DTD file.
[input] xmlns=<uri>
The namespace for the element and autoboot names using prefix.
[input] colon-replacement=<chars>
The character that is used to replace colons in element names. Used when
constructing the names of definitions used to represent the element and attribute list
declarations in the DTD. Trang generates a definition for each element declaration
and attlist declaration in the DTD. The definition name is based on the element name.
In RELAX NG, the definition names cannot contain colons; colons are allowed in
element names in DTDs. Trang first tries to use the element names without prefixes.
If this results in a conflict, Trang replaces the colon with the chars specified. If no
chars is specified, a period is used.
[input] element-define=<name-pattern>
1268
percent character (%). This character is replaced by the name of the element, after
colon replacement, and the result is used as the name of the definition.
[input] inline-attlist / no-inline-attlist
inline-attlist specifies not to generate definitions for attribute list declarations.
Instead, attributes in attribute list declarations are moved into the definitions
generated for element list declarations.
no-inline-attlist generates a distinct definition (with combine=interleave) for
each attribute list declaration in the DTD; each element declaration definition
references the definition for the corresponding attribute list declaration.
[input] attlist-define=<name-pattern>
Specifies how to construct the name of the definition representing an attribute list
declaration from the name of the element. The name-pattern must contain exactly one
percent character (%). This character is replaced by the element name, after colon
replacement, and the result is used as the name of the definition.
[input] any-name=<name>
Specifies the name of the definition generated for the content of elements declared in
the DTD as having a content model of ANY.
[input] strict-any
Preserves the exact semantics of ANY content models by using an explicit choice of
references to all declared elements. By default, Trang uses a wildcard that allows any
element.
[input] annotation-prefix=<prefix>
Specifies whether or not Trang should generate a start element. DTDs do not
indicate what elements are allowed as document elements. Trang assumes that all
elements that are defined but never referenced are allowed as document elements.
[output] encoding=<name>
1269
Disables the use of abstract elements and substitution groups in the generated XML
schema.
[output] any-process-contents=strict|lax|skip
Specifies the value for the processContents attribute of any elements. The default is
strict, which corresponds to DTD semantics.
[output] any-attribute-process-contents=strict|lax|skip
Specifies the value for the processContents attribute of anyAttribute elements. The
default is skip, which corresponds to RELAX NG semantics.
1270
Yellow background indicates that the EDI version specified in the version drop-down
list does not match the EDI version in the document
Red background indicates that the EDI dialect specified in the dialect drop-down list
does not match the EDI dialect in the document
Red squiggles indicate that there is an error for a particular segment. Prev and Next
buttons help you locate errors
The status bar indicates the number of errors (if any) in the document
Quick Fixes on the short-cut menu (right-click on an error) let you modify the XML
Converters properties or the EDI structure to resolve the error
Locate choices on the short-cut menu (right-click any line in the EDI document pane)
let you jump to the related node in the EDI Structure pane
1271
1272
View an EDI file you want to convert to XML. The EDI document pane shows any
errors in the file that is, how the file deviates from the EDI standard on which it is
based and provides Quick Fixes and other tools to help you correct the errors.
Specify properties for the DataDirect XML Converter. The EDI to XML module uses
the DataDirect XML Converter engine to convert EDI to XML. See Specifying
XML Converter Properties for more information on this topic.
Preview the EDI to XML Conversion. When you click the Preview Result button
( ), Stylus Studio opens the Preview window and displays the XML that results
from converting the source EDI document using the parameters specified for the
XML Converter engine as well as changes made to the EDI standard, if any.
1273
Element Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Element Definition dialog box to add an element definition to the EDI
structure associated with your EDI to XML Conversion. The element definition resides in
the SEF file for your EDI to XML Conversion.
Fields
Element Name
The name you want to give to the element. Names are always created in upper case.
Datatype
Choose the datatype for this element from the drop-down list.
Length
Specify the minimum and maximum lengths for this element in the Minimum and
Maximum fields.
Description
1274
Find
Find
Use the Find dialog box to search for text in a document. To display the Find dialog box,
from the Stylus Studio menu bar, click Find
.
Fields
Find what
For example, if you specify that you want to search for style, the search engine does
not find instances of stylesheet.
Match case
Finds instances that exactly match the lowercase and uppercase of the letters you
enter.
Regular expression
Interprets the text in the Find what field as a regular expression and conducts the
search based on that.
Search only inside
Indicate whether you want to restrict the search to element tags, element values,
attribute names, and/or attribute values.
Find Next
Jumps to the next instance of the string you are searching for.
Mark All
Marks each line that contains the text you are looking for. The mark is the light blue
rectangle that is the Bookmark symbol. Click in a line with a mark and then click
Toggle Bookmark
to toggle the display of that flag. Click Previous Bookmark
and Next Bookmark to move from mark to mark. Click Clear All Bookmarks
to remove all marks.
1275
Find (Mapper)
You use the Find dialog box in the XQuery and XSLT Mappers to search for nodes in
source and target document trees. To display the Find dialog box, right-click in the source
or target document pane, and select Find from the shortcut menu.
Fields
Find what
For example, if you specify that you want to search for author, the search engine does
not find instances of authors.
Match case
Finds instances that exactly match the lowercase and uppercase of the letters you
enter.
Regular expression
Interprets the text in the Find what field as a regular expression and conducts the
search based on that.
Search in
Indicate whether you want to restrict the search to element names and/or attribute
names.
Find Next
Jumps to the next instance of the string you are searching for.
1276
File Explorer
File Explorer
You use the File Explorer window to perform basic operations on the files in your Stylus
Studio applications and projects, such as opening a file in Stylus Studio, deleting a file
from a file system, renaming a file, and so on. Rather than selecting File > Open to open
an XML document, for example, you can simply select the document from the File
Explorer window and double-click it or drag it onto the Stylus Studio desktop.
You can also use the File Explorer window to define connections to relational databases
and other file systems (like WebDAV and FTP, for example).
Tip The File Explorer is a docking window, which means you can drag and drop it anywhere
1277
Fields
Target directory
Stylus Studio uses the namespace name to create a folder in the target directory you
specify. If you use myNamespace, for example, the generated code is written to
c:\temp\myPipelineC#Code\myNamespace. (Though optional, it is considered good
practice to create a namespace.)
Class name
Stylus Studio uses the class name for the .cs file created by the Code Generation
wizard. For example, if you provide the name myClass, Stylus Studio creates
c:\temp\myPipelineC#Code\myClass.cs. Stylus Studio uses the XML pipeline name
as the default class name.
Saxon .NET folder
Allows you to specify the location of Saxon .NET on your system. Stylus Studio adds
this URL to the Microsoft Visual Studio 2005 project, allowing the generated C# code
for .NET to compile.
Create a Main method
Whether or not you want the resulting .cs file to contain a static
[ ] args) method.
void Main(String
Execution log
Specifies the argument for the setExecutionLog method in the generated application.
Choices are Console.out (the default), Console.err, and Quiet. Set to Quiet to turn off
the log.
Open the generated file
1278
Whether or not you want to open the generated code file. If selected, the generated C#
file is opened in whatever application is registered to open .cs files.
Embed the XQuery source in the generated program
Whether or not you want to embed the XQuery source in the generated C# code. This
option is available when using either the Saxon XQuery or DataDirect XQuery
processors. This option is available only if the Generate inline code check box is
selected.
Add the class to a Visual Studio 2005 project
Either creates a new Visual Studio 2005 project or updates an existing one. If a new
project is created, it is automatically opened with whatever application is registered
to open .csproj files. The .csproj file contains all the necessary references to the
generated .cs file, as well as all the .dll files that the .cs file requires.
To run the .cs file, simply press Ctrl+F5 in Visual Studio.
1279
Fields
Target directory
The target directory in which you want the Java code created.
c:\temp\myPipelineJavaCode, for example. If the directory you name does not exist,
Stylus Studio creates it when you run the Java Code Generation wizard. The default
is . , which places the generated code in the same directory as the .pipeline file.
Package name
Stylus Studio uses the package name to create a folder in the target directory you
specify. If you specify myPackage as the package name, for example, the generated
code is written to c:\temp\myPipelineJavaCode\myPackage. (Though optional, it is
considered good practice to create a package name.)
Class name
Stylus Studio uses the class name for the .java file created by the Java Code
Generation wizard. For example, if you provide the name myClass, Stylus Studio
creates c:\temp\myPipelineJavaCode\myPackage\myClass.java. Stylus Studio uses the
XML pipeline name as the default class name.
Add to generated to the current project
Whether or not you want to add the generated code to the current project. If you select
this option (it is on by default), the package structure (com.mycompany.payroll, for
example) is used to create a series of project folders at the current projects root
(com\mycompany\payroll, for example). If you use the default package (none), the
name.java file is added under the projects root.
Execution log
Specifies the argument for the setExecutionLog method in the generated application.
Choices are System.out (the default), System.err, and Quiet.
Generate inline code
1280
Whether or not you want to generate inline code. Inline code can be run anywhere,
as-is. If you choose not to generate inline code, you must ensure that the XML
Pipeline Java libraries, xmlpipeline.jar, is in your systems classpath.
Embed the XQuery source in the generated program
Whether or not you want to embed the XQuery source in the generated Java code.
This option is available when using either the Saxon XQuery or DataDirect XQuery
processors. This option is available only if the Generate inline code check box is
selected.
1281
Generate Transformation
XML Publisher is available only in Stylus Studio XML Enterprise Suite.
You use the Generate Transformation dialog box to specify the desired transformation
language (XSLT or XQuery) you want Stylus Studio to use when generating code for your
XML Publisher report.
Fields
Transformation Language
Whether you want Stylus Studio to generate the XML transformation using XQuery
1.0, XSLT 1.0, or XSLT 2.0.
Save Into
The URL to which you want to write the generated XQuery or XSLT. Stylus Studio
uses the .report file name as the default for the generated file.
1282
Fields
Message
You use the fields in the Message group box to specify information about the EDI
standard for which you want to generate an XML Schema.
Dialect Drop-down list that lets you specify the EDI dialect for which you want
to generate an XML Schema.
Version Drop-down list that lets you specify the version for the EDI dialect you
selected.
Mode Certain EDI messages have alternate batch and interactive forms,
depending upon whether they are used between systems that have real-time
connections. The Interactive setting causes the interactive form to be used, if
available. For example, in EDIFACT, this would cause the normal envelope of
UNB/UNH/UNT/UNZ to be replaced by UIB/UIH/UIT/UIZ. Valid for
EANCOM, EDIFACT, and IATA only.
Message/Description The specific EDI message for which you want to generate
XML Schema.
XML Structure
You use the fields of the XML Structure group box to specify the structure of the XML
Use long element names Whether or not you want to use the long element
name as part of the XML tag UNB01-SyntaxIdentifier versus UNB01, for
example.
Wrap GROUP element around message groups Whether you want to wrap
a <GROUP> element around transaction messages. This can make message
groupings easier to handle with XPath for EDI document with multiple message
groups.
Prefix GROUP_N tags with the message name Adds the message name to the
GROUP_n prefix in the XML element tag. For example, <TS_831_GROUP_1>.
Put the data value in value= attributes Places code list data values in an value=
string in the element tag. For example, <BGN01 value="00"><!--353: Transaction
Set Purpose Code--></BGN01>. By default, the data value is output to XML as text
(<BGN01><!--353: Transaction Set Purpose Code-->00</BGN01>).
Stylus Studio User Guide
1283
Put decoded data values in decode= attributes Places decoded code list data
The fields in this group box allow you to specify the settings that are used to generate
the XML Schema for the selected EDI message.
Write annotations describing each element Whether or not you want the
generated XML Schema to include annotations that are part of the EDI message.
Enumerations for elements that have codelists Whether or not you want the
generated XML Schema to include enumerations for fields that have lists of
values.
when generating XML Schema. The SEF file can augment information that Stylus Studio
uses to generate XML Schema customized EDI definitions are stored in the SEF file,
for example. If the same setting is specified by both the document wizard and the SEF file,
the SEF file value is used.
1284
Fields
Message
You use the fields in the Message group box to specify information about the EDI
standard for which you want to generate XQuery.
Dialect Drop-down list that lets you specify the EDI dialect for which you want
to generate XQuery.
Version Drop-down list that lets you specify the version for the EDI dialect you
selected.
Mode Whether the EDI is processed in batch or interactive mode. Valid for
EANCOM, EDIFACT, and IATA only.
Message/Description The specific EDI message for which you want to generate
the XQuery.
XML Structure
You use the fields of the XML Structure group box to specify the structure of the XML
Use long names for Whether or not you want to use the long element and/or
segment names as part of the XML tag UNB01-SyntaxIdentifier versus UNB01,
for example.
Wrap GROUP element around message groups Whether you want to wrap
a <GROUP> element around transaction messages. This can make message
groupings easier to handle with XPath for EDI document with multiple message
groups.
Prefix GROUP_N tags with the message name Adds the message name to the
GROUP_n prefix in the XML element tag. For example, <TS_831_GROUP_1>.
Put the data value in value= attributes Places code list data values in an value=
string in the element tag. For example, <BGN01 value="00"><!--353: Transaction
Set Purpose Code--></BGN01>. By default, the data value is output to XML as text
(<BGN01><!--353: Transaction Set Purpose Code-->00</BGN01>).
Put decoded data values in decode= attributes Places decoded code list data
values in a decode= string in the element tag. For example, <ISA15
decode=Production Data>. By default, the decoded value is not output to XML.
1285
You use the XQuery Generation Options group box to specify what EDI structures
you want represented in the generated XQuery. XQuery resulting from the document
wizard is output as an Untitledn.xquery file, where n is a unique number, directly to
the Stylus Studio desktop.
Mandatory segments and elements only Generates only those segments whose
Requirement property is mandatory and, for them, only the mandatory element
and composite references.
All segments but only mandatory elements Generates all segments, but, for
each of them, only the mandatory element and composite references.
All segments and elements Generates all segments, and all element and
composite references specified for them.
Create XML Schema for this EDI Message
In addition to generating XQuery for an EDI message, you can choose to generate an
XML Schema for the same message at the same time. The fields in this group box
allow you to specify the settings that are used to generate the XML Schema for the
selected EDI message.
XSD File The URI for the XML Schema (.xsd) file that is output by the
document wizard.
Write annotations describing each element Whether or not you want the
generated XML Schema to include annotations that are part of the EDI message.
Enumerations for elements that have codelists Whether or not you want the
generated XML Schema to include enumerations for fields that have lists of
values.
when generating XML in XQuery and XML Schema files. The SEF file can augment
information that Stylus Studio uses to generate XQuery and XML Schema customized
EDI definitions are stored in the SEF file, for example. If the same setting is specified by
both the document wizard and the SEF file, the SEF file value is used.
1286
1287
Fields
Message
Displays the name of the message; based on the message that was active in the EDI
Structure pane of the EDI to XML editor when you selected EDI > Generate
XQuery/XML Schema from the menu.
Mode
Whether the EDI is processed in batch or interactive mode. Valid for EANCOM,
EDIFACT, and IATA (Cargo-IMP and PADIS) only.
Create XQuery for this EDI Message A check box you use to indicate that you want to
XQ File The URI for the file to which the generated XQuery is written. By
default, this is Untitledn_name.xquery file, where n is a unique number and name
is the EDI message name abbreviation.
Mandatory segments and elements only Generates only those segments whose
Requirement property is mandatory and, for them, only the mandatory element
and composite references.
All segments but only mandatory elements Generates all segments, but, for
each of them, only the mandatory element and composite references.
All segments and elements Generates all segments, and all element and
composite references specified for them.
Create XML Schema for this EDI Message A check box you use to indicate that you
want to generate XML Schema for the EDI message.
XSD File The URI for the file to which the generated XML Schema is written.
By default, this is Untitledn_name.xsd file, where n is a unique number and name
is the EDI message name abbreviation.
Write annotations describing each element Whether or not you want the
generated XML Schema to include annotations that are part of the EDI message.
1288
Enumerations for elements that have codelists Whether or not you want the
generated XML Schema to include enumerations for fields that have lists of
values.
Use unbounded for maxOccurs when loop value is 99 or higher) Replaces
maxOccurs values of 100 or greater with unbounded. This option ensures that
the generated XML Schema can be successfully validated by most processors.
1289
The file
A region
A row
Fields
Cursor Position in File
Go To Displays the cursors current position in the file, and allows you to specify
which you want to move the cursor. This field is grayed out if the file has only one
region.
Maximum The total number of regions in the file. Read only.
Cursor Position in Region
Go To Displays the cursors current position in the region, and allows you to specify
the position to which you want to move the cursor.
Maximum The total number of characters in the current region. Read only.
Row in Current Region
Go To Displays the cursors current row, and allows you to specify the row to which
1291
Go To
Use the Go To dialog box to specify the number of a line you want to jump to. To display
the Go To dialog box, in the Stylus Studio tool bar, click Go to a specified location
.
Fields
Enter the line number
1292
Group Definition
Group Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Group Definition dialog box to add a group definition to a message or another
group. The group definition, as well as the modified message or group definition, resides
in the SEF file for your EDI to XML Conversion.
Fields
Choose a loop trigger
The first segment in a group is referred to as the loop trigger. You can choose an
existing segment from the Choose a loop trigger drop-down list, or create a new one
by clicking the New Segment button. Clicking the New Segment button displays the
Segment Definition dialog box, which you use to create the new segment.
Group label (optional)
Use this field to provide a group label (GROUP_9, for example). If you leave it blank,
Stylus Studio assigns a unique group label.
Modifier
Indicates whether the group is used in your customized EDI structure. For new
groups, you can leave this field empty. If you are modifying an existing group because
you want to indicate that it is not used in your customized EDI structure, set Modifier
to Not Used instead of removing the group from the EDI structure.
Valid values for this property are Dependent, Must be used, Not recommended, Not
used, Recommended.
Requirement
The number of times the group can appear in the associated message or group.
Ordinal
The groups place within the associated message or group. This field is grayed out
unless you have set the EDI Structure Loop Sequence Enabled property to True.
Default value if present, has been calculated not to interfere with other segments or
groups in the message.
1293
The position within the associated message or group at which the group starts. This
field is grayed out unless you have set the EDI Structure Loop Sequence Enabled
property to True. Default value if present, has been calculated not to interfere with
other segments or groups in the message.
1294
Fields
Skip it
Stylus Studio skips the illegal character and opens the file.
Preserve it
Stylus Studio preserves the illegal character, rendering it in the editor using whatever
means possible when the file is opened.
Escape it
Stylus Studio escapes the illegal character using Unicode when the file is opened.
Report the error
Stylus Studio displays an error concerning the illegal character like this:
Byte 0x92 found in file file://\\my_server\XqueryRoot\connectionpooling\index.html at offset 5547 is invalid for encoding utf-8
Stylus Studio does not open the file if you choose to report the error.
1295
Import File
You use the Import File dialog box to select the WSDL document that you want to import
into the current WSDL document.
Fields
Document Location
The URL of the WSDL document you want to import into the current WSDL
document. You can use the browse button ( ) to navigate file systems, or you can
type the complete path yourself.
1296
Imported Files
Imported Files
You use the Imported Files dialog box to add (wsdl:import) external WSDL documents
to the current WSDL document. You might want to use this feature if you have a library
of messages, for example, defined in another WSDL document that you want to use in the
current WSDL document.
Fields
Files imported by this document
The URL and namespace of any WSDL documents referenced by the current WSDL
document. By default, this list box shows any imported WSDL documents already
defined in the current WSDL document.
Buttons
Add
Displays the Import File dialog box, which allows you to specify the WSDL
document you want to import in the current WSDL document. When you add a
WSDL document, Stylus Studio adds an <import> element whose location= attribute
is taken from the URL you selected when adding the WSDL document via the Import
File dialog box.
Remove
Removes the reference to the selected WSDL document from the current WSDL
document.
1297
Imported Modules
You use the Imported Modules dialog box to manage imported modules in an XQuery.
The Imported Modules dialog box
Displays any modules that have already been imported into the XQuery
Fields
Namespace
Buttons
Add
Displays the Open dialog box, which allows you select a module to import.
Remove
1298
In XQuery, to register the Java class associated with a custom URI resolver
In XSLT, to register a Java extension class. This dialog box can also appear during
stylesheet debugging when processing reaches the invocation, Stylus Studio
displays this dialog box and prompts you to indicate where it can find the Java file.
Fields
Class Name
For XSLT
Defining Java Functions in the XSLT Mapper on page 540
Overview of the XSLT Mapper on page 508
Debugging Stylesheets on page 551
1299
Fields
Target directory
The directory to which you want to write the generated code. You can
The name you want to use for the Java package generated from the XQuery or XSLT.
Left blank by default.
Class name
The name you want to use for the Java class generated from the XQuery or XSLT. By
default, this is the name of the XQuery or XSLT document for which you are
generating Java code.
Add generated code to the current project
Whether or not you want to add the generated code to the current project. If you select
this option (it is on by default), the package structure (com.mycompany.payroll, for
example) is used to create a series of project folders at the current projects root
(com\mycompany\payroll, for example). If you use the default package (none), the
name.java file is added under the projects root.
Embed the XQuery source in the generated program
Whether or not you want to embed the XQuery source in the generated Java code.
This option is available when using either the Saxon XQuery or DataDirect XQuery
processors.
Note: This option appears only if you are generating XQuery code.
1300
1301
Java Editor
To display the Java editor in Stylus Studio, select File > New > Java: Text Editor from the
Stylus Studio menu bar.
Alternative: In Stylus Studio, open a file with .java as the file name extension. Stylus
Studio automatically opens the file in the Java editor.
Use the Java source editor to write, update, and compile Java source files.
Fields
Compile the Java source file.
Change the font used to display text in the Java editor.
1302
Fields
Class Name
1303
Keyboard Accelerators
This section lists and describes Stylus Studio keyboard accelerators and function keys for
the following:
File Commands
Table 191. File Commands
Accelerator
Operation
Ctrl+N
Opens the Scenario Properties dialog box so that you can define
a new scenario.
Ctrl+O
Displays the Open dialog box. You can open any kind of document
that Stylus Studio handles.
Ctrl+S
General Commands
Table 192. General Commands
1304
Accelerator
Operation
F1
F2
F5
F12
Ctrl+F2
Inserts a bookmark.
Keyboard Accelerators
Table 192. General Commands
Accelerator
Operation
Shift+F2
Ctrl+Shift+F2
Editing Commands
Table 193. Editing Commands
Accelerator
Operation
Ctrl+A
Ctrl+C
Ctrl+F
Ctrl+H
Replaces text.
Ctrl+V
Ctrl+X
Removes selected text from the window in which you are editing
and places it on the Clipboard.
Ctrl+Y
Ctrl+Z
F3
Debugging Commands
Table 194. Debugging Commands
Accelerator
Operation
F9
Inserts a breakpoint.
F10
Step over.
F11
Step into.
1305
1306
Accelerator
Operation
Shift+F5
Stop debugging.
Shift+F11
Step out.
Lookup List
Lookup List
The Custom XML Conversion module is available only in Stylus Studio XML
Enterprise Suite.
You use the Lookup List dialog box to enter name:value pairs. When files are converted
to XML, Stylus Studio uses the information in the lookup list to translate a name (or code)
to a corresponding value. For example, you might have a lookup list that contains state
abbreviations and their full names, or error codes and the corresponding descriptions. You
can enter lookup list values manually, or by copy/pasting tab- and comma-separated text
files into the Lookup Value table in the Lookup List dialog box.
Fields
Lookup
Buttons
OK
Closes the Lookup List dialog box without committing any changes.
Copy
Pastes comma- and tab-separated text into the lookup list. Replaces existing content,
regardless of which row you have selected.
Append
Adds comma- and tab-separated text to the end of the lookup list. Existing lookup list
content is preserved.
Insert
1307
1308
Message Definition
Message Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Message Definition dialog box to add a message definition to the EDI
structure associated with your EDI to XML Conversion. The message definition resides
in the SEF file for your EDI to XML Conversion.
Fields
Message Name
The name you want to give to the message. Names are always created in upper case.
Description
1309
Name
XQuery support is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
You use the Name dialog box to specify the name of one of the following in a target
structure in the XQuery mapper:
Element name
Attribute name
This dialog box appears when you
Fields
Name
The Name field is empty if you are adding a new element or attribute to the target
structure. It contains the source document element or attribute name if you are
mapping a source document element or attribute to the target.
1310
Named Template
Named Template
The Named Template dialog box displays the name and mode of the template you have
selected from the mapper canvas in the XSLT mapper.
Fields
Name
The template mode. You can use a mode to define the conditions under which a
template will be applied by a stylesheet.
1311
Named/Matched Template
Use the Named Template or the Matched Template dialog box to create a new named or
matched template in an XSLT stylesheet. In addition to specifying the templates name
and mode, you can also define template parameters and their default values.
Fields
Name
The template mode. You can use a mode to define the conditions under which a
template will be applied by a stylesheet.
Parameter List
A list box that displays the parameters, and their default values, associated with this
template.
2.
3.
4.
If you want to define another parameter, click ADD; otherwise, click OK to finish
creating the template.
1312
Fields
1. Select an input file to be converted to XML
The type of encoding used by the input file. You can specify this manually, if you
know it, using The encoding is field, or you can let Stylus Studio determine the
encoding when it reads the file (this is the default).
3. Specify the general layout of the file
Whether the input file is line-oriented or fixed-width. You can choose one of these
settings, or you can let Stylus Studio determine the file layout when it reads the file
(this is the default).
1313
Use an existing EDI document and see how it differs from the EDI standard on which
it is based
Select an EDI standard and customize its definitions based on your organizations
proprietary EDI format
It is usually easier to start with an EDI document to understand where and how it differs
from the EDI standard on which it is based.
Fields
Select a sample EDI document
Use this field to specify the EDI document you want to use as the model for
customizing the EDI standard.
Select the dialect and version you need to customize
Use this field specify the dialect and version of the EDI standard you want to modify.
Dialect
The dialect of the EDI standard whose definitions you want to modify. This field is
grayed out if you choose to create the EDI to XML conversion using an EDI
document.
Version
The version of the EDI dialect whose definitions you want to modify. This field is
grayed out if you choose to create the EDI to XML conversion using an EDI
document.
1314
1315
New Function
XQuery support is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
You use the New Function dialog box to create a user-defined function based on code that
you have selected in the XQuery text editor. This command prompt for a function name
and then copies the selection into the newly created local function, and replaces the
selection with the function call.
Fields
Enter the name for the new function
The Enter the name for the new function field contains a default name, udFunctionN,
where ud stands for user-defined and N is a unique number.
You can specify any valid name you choose.
1316
Notes
Notes
The Custom XML Conversion module is available only in Stylus Studio XML
Enterprise Suite.
You use the Notes dialog box in the Custom XML Conversion XML Editor to create notes
and comments for a given row. Notes are stored with the XML conversion and do not
affect converted XML.
1317
opening a file.
Use the Save As dialog box to
Fields
Look in
Specifies the directory whose contents are currently displayed in the main field of the
dialog box. Click the down arrow to navigate to a different directory.
URL:
Displays the name of the file you select, or you can type the name.
Files of type:
Specifies which file types can appear in the main field of the dialog box. The default
is that Stylus Studio displays files with file name extensions of .dtd, .java, .xml, .xsd,
and .xsl. To change the file types Stylus Studio displays, click the down arrow and
select the filter you want. To allow display of any type of file, select All Files (*.*).
Open using XML Converter
Check if you want to open a non-XML file (such as a text, binary, or EDI file) using
an XML conversion, such as one you have created using Stylus Studios Custom
XML Conversion module. When you click the Open button, Stylus Studio displays a
dialog box from which you can select the XML conversion you want to use. See
Converting Non-XML Files to XML for more information on this topic.
Buttons
Click My Computer to open a file in your local file system or on a networked file
system.
1318
Click WebDAV Server to open a file that is stored on a WebDAV server. WebDAV is
a protocol that allows programs to access a repository of files using HTTP commands,
enabling a web server to act as a file distribution and sharing point. You can use WebDAV
to read any file from any HTTP or HTTPS source, or to save a file to a web server that is
properly configured for write access.
Click FTP Server to open a file that is stored on an FTP server. FTP is a protocol that
allows two computers connected over the Internet to share files. In an FTP configuration,
one computer is configured as a server; the other is configured as a client.
Click TigerLogic XDMS to open a file that is stored on a TigerLogic XDMS database.
You will be prompted for authentication information.
Click Up to move up one level in the directory structure.
Click New Folder create a new directory in the directory you are viewing.
Click these buttons to toggle the display of the Name and Size headings in the main
field of the Open dialog box.
1319
Options
The Options dialog box contains general and module-specific settings that allow you to
customize Stylus Studio defaults. Categories are organized by general application settings
and module-specific settings.
To get help on a specific category, select that category and press F1.
1320
Fields
Automatically check for externally modified files
If there are files that are part of your XML application and they are modified outside
Stylus Studio while you are working on the application in Stylus Studio, Stylus Studio
prompts you to indicate whether you want to update the file in Stylus Studio.
Disable check on hidden files
Hidden files are files that are in the Stylus Studio project or the Other Documents
folder but not open in Stylus Studio windows. In some situations, it is useful to refresh
your open files after hidden files have been updated. In other situations, doing this is
unnecessary.
Automatically save modified files every nnn minutes
You can specify whether and how often you want Stylus Studio to automatically save
your open files.
Automatically create backup copy (*.bak) on save
Whether or not you want Stylus Studio to create a backup copy of your documents
when they are saved. Files saved to the Stylus Studio file system are saved with a
*.bak extension. Backup file names for files saved to other file systems (like Tiger
Logic XDMS, for example) are managed by the file system. The option to create
backup files is on by default.
Automatically add the Base Catalog to new projects
The Stylus Studio Base Catalog, which is bundled with every Stylus Studio
installation, is a collection of over one dozen popular catalogs that conform to the
OASIS catalog standard. By adding the Base Catalog to a project, any XML file in
the project that are associated with files inside the catalog (a schema or DTD, for
example) is validated against that catalog file.
Recent file lists
Specifies the number of files you want to display on File and Project menus. Changes
to these settings take effect the next time you start Stylus Studio.
Stylus Studio User Guide
1321
On File menu
On Project menu
Stylus Studio automatically opens the project that was open the last time you
closed Stylus Studio.
Stylus Studio automatically opens any files that were open the last time you
closed Stylus Studio.
Check for newer versions
Specifies whether Stylus Studio automatically checks the Stylus Studio Web site to
determine if a newer version of Stylus Studio is available. If a newer version is
detected, Stylus Studio displays an animated button in its status bar. Click the button
to download the new version.
User interface
Displays multiple documents as individual windows which you can tile, cascade,
and so on.
Displays multiple documents as tabs that are displayed at the top of the editor
window. This is the default.
Whether or not to display the Stylus Studio help window on top of the Stylus
Studio application.
1322
Fields
Back-mapping to the language (XSLT/XQuery) source on left mouse click
Indicates whether or not you want enable back-mapping to the XSLT/XQuery source
and, optionally, whether or not you want to require that the Shift, Ctrl, or both keys
be used with the mouse click action in order to invoke back-mapping:
The Shift key must be used with the left mouse click to invoke back-mapping.
The Ctrl key must be used with the left mouse click to invoke back-mapping.
Back-mapping to the data (XML) source on left mouse click
Indicates whether or not you want enable back-mapping to the XML source and,
optionally, whether or not you want to require that the Shift, Ctrl, or both keys be used
with the mouse click action in order to invoke back-mapping:
The Shift key must be used with the left mouse click to invoke back-mapping to
the XML source.
The Ctrl key must be used with the left mouse click to invoke back-mapping to
the XML source.
1323
Fields
DataDirect XML Converters for Java Folder
This field displays the path of the folder in which XML Converters is installed. By
default, it points to the copy of XML Converters installed with Stylus Studio, but
you can use it to point to a standalone installation.
License Manager
This group box lists the existing licenses for the copy of XML Converters identified
in the DataDirect XML Converters for Java Folder field.
1324
Fields
DataDirect XML Converters for .NET Folder
This field displays the path of the folder in which XML Converters is installed. By
default, it points to the copy of XML Converters installed with Stylus Studio, but
you can use it to point to a standalone installation.
License Manager
This group box lists the existing licenses for the copy of XML Converters identified
in the DataDirect XML Converters for .NET Folder field.
1325
Fields
DataDirect XML Converters for XQuery Folder
This field displays the path of the folder in which DataDirect XQuery is installed. By
default, it points to the copy of DataDirect XQuery installed with Stylus Studio, but
you can use it to point to a standalone installation.
License Manager
This group box lists the existing licenses for the copy of DataDirect XQuery
identified in the DataDirect XML Converters for XQuery Folder field.
1326
Fields
Document type
From the drop-down menu, select the type of document that will be imported by
Stylus Studio. This is the output of your document wizard and it can be any of the
types listed in the Stylus Studio File > New menu. Required.
The value you specify here determines the Document Wizards tab on which the icon
for your application appears and the editor Stylus Studio uses to open the output file.
Icon bitmap
Specify the path for the file that contains the bitmap to be used as the icon in the
Document Wizards dialog box. If you do not specify a location, Stylus Studio
displays a default bitmap for your wizard. Click
to browse for the file you want
to specify or to insert the ${StylusDir} macro. This macro indicates that the path you
specify is relative to the Stylus Studio installation directory.
Command
Specify a command line template that Stylus Studio can use to generate the command
that starts your application. This should be the same as the command that starts your
application except that it has variables in place of actual arguments.
Click
to display a menu that provides shortcuts that help you specify the
command line. From this menu you can
Click Edit Arguments to specify arguments and their properties. After you define
an argument, its macro appears in this shortcut menu and you can select it.
Insert the ${StylusDir} macro to indicate that a path you specify is relative to the
Stylus Studio installation directory.
1327
It is often easier to define arguments and then specify the command line.
The variables must be in the form ${name}. For example:
${InputFile}
${OutputFile}
${LoggingOption}
${SomeArgument}
The variables can appear anywhere in the command. There must be a one-to-one
correspondence between these variables and the list of arguments that you specify for
the executable when you click Arguments.
This property is required. You must at least specify ${OutputFile} even if the
command line has no arguments. Stylus Studio generates the value for the
${OutputFile} argument, which is the name of the file that is opened in Stylus Studio.
For example:
java -cp my.jar com.exln.stylus.Import ${QuoteChar} ${InputFile} ${OutputFile}
This starts the specified Java class with a command line that includes the QuoteChar,
InputFile, and then OutputFile arguments. To specify properties for the QuoteChar
and InputFile arguments, click Arguments.
Initial directory
Specify the directory that you want Stylus Studio to set as the current directory when
starting your application. Click
to browse for the file you want to specify or to
insert the ${StylusDir} macro. This macro indicates that the path you specify is
relative to the Stylus Studio installation directory.
Path
Define any paths required to execute your application. You do not need to specify
paths that are already in your PATH environment variable. If you specify more than one
path, separate them with semicolons. Click
to display a menu that provides
shortcuts that help you specify the PATH field. From this menu you can
Insert the ${StylusDir} macro to indicate that a path you specify is relative to the
Stylus Studio installation directory.
Boolean value that indicates whether you want Stylus Studio to display tracing
information about the selection and execution of the document wizard in the Output
Window. This is meant to be used during the development of the custom document
1328
wizard and not during normal use of the wizard. This is an optional property. By
default, it is false.
Buttons
Arguments
Define a new custom document wizard. Stylus Studio displays a field for the new
wizards name. Specify the text that you want to appear below the custom document
wizards icon in Stylus Studios Document Wizards dialog box. For example, Proprietary
to XML.
Delete the selected custom document wizard.
Move the selected custom document wizard one place up in the list of custom
document wizards. The order of the wizards here determines the order of the selections in
the Stylus Studio Document Wizards dialog box.
Move the selected custom document wizard one place down in the list of custom
tools.
Displays a pop-up list of alternatives that help you specify the corresponding field.
1329
on page 122.
Fields
Command
Specify or select the absolute path of the command that starts your tool. This can be
a .exe, .bat, or .cmd file.
Arguments
Specify any arguments required by your tool. For typical arguments, such as path,
directory, name, extension, or classpath, click .
Initial directory
Specify the directory that you want Stylus Studio to use to find any files needed to
start your process.
Path
Define any paths required to execute your tool. You do not need to specify paths that
are already in your PATH environment variable.
Prompt for arguments
If you specify any arguments here, then after you select your custom tool from the
Stylus Studio Tools menu, Stylus Studio displays a dialog box that prompts for the
arguments.
Use Output Window
When selected, Stylus Studio displays output from your custom tool in the Stylus
Studio Output Window.
Save All documents before execution
Prompts Stylus Studio to save all open documents before running this tool.
1330
Buttons
Define a new custom tool.
Delete the selected custom tool.
Move the selected custom tool one place up in the list of custom tools. The order of
the tools here determines the order of the selections in the Stylus Studio Tools menu.
Move the selected custom tool one place down in the list of custom tools.
Browse the file system.
Display a pop-up list of variables.
1331
Fields
Command
Specify or select the absolute path of the command that starts the validation engine.
This can be a .exe, .bat, or .cmd file.
Arguments
Specify any arguments required by your validation engine. For typical arguments,
such as path, directory, name, extension, or classpath, click
.
Initial directory
Specify the directory that you want Stylus Studio to use to find any files needed to
start your process.
Path
Define any paths required to execute the validation engine. You do not need to specify
paths that are already in your PATH environment variable.
Classpath
You use the Classpath field to specify the required classpath for the custom validation
engine.
To enter a classpath, type the value or click Browse to the right of the field.
Prompt for arguments
If you specify any arguments here, then after you select the validation engine from the
Validate Document drop-down list, Stylus Studio displays a dialog box that prompts
for the arguments.
Supports Validation of XML
Whether or not the custom validation engine supports validation of XML Schema.
1332
Buttons
Define a new custom validation engine.
Delete the selected validation engine.
Move the selected validation engine one place up in the list of custom validation
engines. The order of the validation engines here determines the order of the selections in
the Validate Document drop-down list.
Move the selected validation engine one place down in the list of validation engines.
Browse the file system.
Display a pop-up list of variables.
1333
Fields
Editor
Click the down arrow to select the editor for which you want to specify options (Java,
XML, or XSLT).
Default Font
Click the down arrow to display a list of fonts. Stylus Studio uses the font you select
to display text in the specified editor.
Size
Click the down arrow and click the font size you want for the selected editor.
Colors
Click a component in the left field, and then click the color you want it to have in the
selected editor display.
Sample
Shows you how the selected font, size, and color appear.
Buttons
Other
Displays an expanded palette of colors and allows you to define custom colors.
Reset All
Returns the options for the specified editor back to their default values.
1334
Fields
Editor
Click the down arrow to determine whether you are specifying options for the Java,
XML, or XSLT editor.
Newline format
Allows you to choose the newline format for documents you open in Stylus Studio:
Windows
UNIX
MacIntosh
Show line numbers
Displays line numbers at the beginning of every line in the editor display.
Line wrap
Stylus Studio automatically wraps lines whose length exceeds 16k characters. You
can turn off this option by selecting Disabled from the Line wrap drop-down list. You
can override this option for individual documents by selecting Edit > Wrap Lines from
the Stylus Studio menu, or by clicking the wrap lines button on the tool bar ( ).
Enable spell checking
Whether or not you want the Spell Checker enabled for this editor. This option is off
by default. The Spell Checker can be run manually from the menu (Tools > Check
Spelling), regardless of how the Enable spell checking option is set.
Word delimiters
Characters you want the Stylus Studio editor to recognize as word delimiters.
Indenter Settings
Preserve trailing/leading whitespace
1335
When checked, this indicates that Stylus Studio preserves (does not trim) white space
that is at the beginning or end of a text node.
Preserve newlines between elements
When checked, this indicates that Stylus Studio preserves (does not remove) new line
characters that are in white space.
Wrap attributes if they exceed column
Instructs Stylus Studio to display the attribute on a new line if it starts after the
specified column. The default column is 256.
Tab Settings
Keep Tabs
Whether you want to keep the tabs in a document or replace tabs with the number of
spaces indicated in the Tab Size field.
Insert Spaces
Whether you want to use spaces instead of tabs. (The number of spaces is specified
using the Tab Size field.)
Tab Size
Check this box if you want the comment at the end of documents created with the
selected editor.
1336
Fields
Sense:X
Sense:X enabled
Click the check box to determine whether Sense:X completion is enabled. If this is
not checked, Stylus Studio does not display pop-up menus that list the possible
elements or attributes that you can create at particular locations.
Automatically insert attribute value
Click the check box to determine whether Stylus Studio automatically inserts
attribute values. Stylus Studio uses this setting when you choose an attribute from the
Sense:X list. When this is checked, Stylus Studio inserts attribute_name=". When
this is not checked, Stylus Studio inserts attribute_name.
Auto-close open tag when typing '</'
As soon as you type </, Stylus Studio completes the tag with the nearest previous
open tag name.
Add closing tag when creating new tag
As soon as you type a new tag, Stylus Studio inserts its closing tag. For example, if
you type <newtag>, Stylus Studio immediately inserts </newtag>.
Dropdown Delay
Specify how long Stylus Studio waits before it displays drop-down lists.
XML Generations
In addition to auto-complete for element names, Sense:X can generate an entire XML
subtree based for a given element. As you type, Stylus Studio displays a drop-down
list with valid choices based on the current context.
1337
The first item for a given element (authors, for example) represents the element tag;
the second item for the same element represents the entire subtree for that element.
You use this option to choose whether
To omit the generated XML from the drop-down. You can still add generated
XML to your document when this option is selected by pressing the Ctrl key
when selecting the element from the drop-down list.
Maximum XML Depth
The depth of an XML elements subtrees you want to include when using automatic
XML generation.
Repeating Elements
The number of repeating elements you want to include when using automatic XML
generation.
Preferred This value is used if it is between the minOccurs and maxOccurs values
defined in the associated XML Schema. The default preferred recursion value is
Maximum This value is used when Preferred is less than minOccurs or greater
than maxOccurs and Maximum is less than maxOccurs.
Number of Repeating Elements
You use the Number of Repeating Elements fields to control the number of repeating
elements Stylus Studio generates in an XML document based on an XML Schema.
Preferred The number of repeating elements you would like Stylus Studio to
generate. This number is used when its value falls between the minOccurs and
maxOccurs values defined for the element in the XML Schema. If this number is less
than the minOccurs value, the minOccurs number of elements is generated, ensuring
that the resulting document is valid. If this number is greater than the maxcOccurs
value, the maxOccurs number of elements.
Maximum This value is used when the Preferred value is out of the range of the
minOccurs and maxOccurs values (less than minOccurs or greater than maxOccurs), and
Maximum is less than maxOccurs.
Optional Elements and Attributes
Whether or not you want to generate optional elements and attributes specified in the
XML Schema, and whether or not you want to generate comments.
1338
By default, Stylus Studio generates all choices and substitutions specified in the XML
Schema, commenting (//) all but the first one to ensure that the generated XML
document is valid. If you prefer, you can generate
All choices and substitutions, without comments. This will result in an invalid
XML document
1339
Change the setting that makes Stylus Studio the default editor for Stylus Studio file
types (.xml, .conv, .prj, and so on) opened outside of Stylus Studio (as from a file
browser like Windows Explorer, for example)
Associate new file types with Stylus Studio and, optionally, make Stylus Studio the
default editor
To display the Options dialog box, select Tools > Options from the Stylus Studio menu
bar.
Buttons
Add
Click the Add button to make the Type field editable. You can also double-click the
Type field to make it editable.
Delete
Click the Delete button to delete a file type from the File Type page.
Fields
Type
The Stylus Studio module or editor associated with the file in the Type field. Clicking
the Module field displays a list of the modules you can associate with a file.
Open with Stylus Studio
Whether or not you want files of the type represented by the Type field to be opened
in Stylus Studio when opened from a file browser like Windows Explorer. Values are
True and False.
1340
Fields
Enable JVM
Indicates whether Stylus Studio loads a JVM. If you do not need a JVM, you can
disable this option so that Stylus Studio requires less memory.
JRE Version
The version of the JRE installed on your system. You can use the Auto detect button
to have Stylus Studio determine the JRE version on your system. (The version is also
displayed on the About dialog box (Help > About).)
Parameters
Parameters for starting the JVM in the context of Stylus Studio. As a rule, you should
never change the default value. This option exists for situations in which there is an
unusual configuration. In such situations, Technical Support might instruct you to
change this value.
JDK
JDK Version
The version of the JDK installed on your system. You can use the Auto detect button
to have Stylus Studio determine the JDK version on your system. (The version is also
displayed on the About dialog box (Help > About).)
Javac Parameters
Parameters for starting the external JVM. As a rule, you should never change the
default value. This option exists for situations in which there is an unusual
configuration. In such situations, Technical Support might instruct you to change this
value.
Debugging Parameters
1341
Detects the JVM installed on your system; resets JVM options if you have changed
them.
1342
Fields
Default Language
Specifies the language (and, therefore, the dictionary) you want the Spell Checker to
use. The default is English (United States).
Capitalized words?
Whether or not you want the Spell Checker to skip capitalized words like Boston Red
Sox and Moto Guzzi.
Mixed-Case words?
Whether or not you want the Spell Checker to skip mixed-case words like DataDirect.
Uppercase words?
Whether or not you want the Spell Checker to skip upper case words like BMW and
USDA.
Words with embedded digits?
Whether or not you want the Spell Checker to skip words with embedded digits like
W3C and R1150RS.
E-mail and URIs?
Whether or not you want the Spell Checker to skip e-mail addresses and URIs like
[email protected].
Words with n or fewer characters?
Whether or not you want the Spell Checker to skip words that have the same or fewer
characters as the value you specify.
Ignore case?
Whether or not you want the Spell Checker to ignore case for spelling purposes. If
this field is checked, BMW and bmw are considered equivalent, for example.
Ignore accents?
Whether or not you want the Spell Checker to ignore accents for spelling purposes. If
this field is checked, mme and meme are considered equivalent, for example.
Highlight repeated words?
1343
Whether or not you want the Spell Checker to highlight doubled (repeated) words. If
this field is checked, the second word in the pair of repeated words is highlighted.
Performance
Allows you to adjust the Spell Checker for speed versus quantity of suggested
alternatives to misspellings.
Keyboard Layout
The type of keyboard you are using. Stylus Studio uses this setting to check for
typographical errors as you type.
1344
Fields
Delay before refreshing the EDI viewer after a change
When you make a change to either the converter:EDI URI or the EDI structure, Stylus
Studio refreshes and reparses the EDI source document specified in the EDI to XML
scenario. This field controls the number of seconds to wait after the last detected
change before refreshing the document.
Background color for mismatched dialect
The background color to use when the EDI dialect specified in the document does not
agree with the dialect specified in the EDI to XML Conversions editor.
Background color for mismatched version
The background color to use when the EDI version specified in the document does
not agree with the version specified in the EDI to XML Conversions editor.
1345
Fields
Source Path
If Stylus Studio cannot find the source files, indicate if you want to be prompted to
specify the source file location.
Never step into classes starting with one of the following strings of characters
List of classes, one on each line, that you do not want to step into.
JVM communication time out
Number of seconds Stylus Studio waits for a response from the JVM. The default is 5.
Show JDWP Events in the Output Window
1346
Example
By default, Name, Binding, Address Type, and Address properties are shown for all port
elements, as shown in the following illustration. Notice that even properties that do not
have a value defined for them are displayed:
1347
set are displayed in the diagram. (In this example, notice that the Address property is no
longer displayed.)
the diagram.
Fields
Category/Property
The node and, optionally, properties whose inline visibility settings you want to
change.
Inline visibility in diagram
The conditions under which you want to display a property and its values in the
WSDL diagram. Inline visibility options are:
Hide The property and its value are always hidden. This is the default for most
elements.
Show The property and its value are always displayed, even if the property does
not have a value.
Show if not empty The property and its value are displayed only if the property
has a value. Properties with a default value (maxOccurs=1, for example) and
properties for which no value has been explicitly set do not appear using this
setting.
Tip If all of a nodes properties have the same show/hide setting (all are set to Hide, for
example), that value is displayed in the Inline Visibility in Diagram field. If no value is
displayed in the Inline Visibility in Diagram field, it means that two or more properties
1348
1349
Fields
General
The fields in the General group box affect when the Stylus Studio diffing engine runs
and basic document handling behavior.
Automatically expand all diffs By default, Stylus Studio collapses the display
of the diffed documents. If you select this option, all nodes containing diffs are
expanded automatically when the diff is run.
Collapse unchanged blocks By default, Stylus Studio collapses any block that
does not contain any changes to save space in the XML Diff Viewer window. You
might prefer to have the entire document structure visible, to provide context for
changed nodes, for example.
Autorun diff By default, Stylus Studio runs the diff operation if you make a
change to one of the settings on the Engine page of the Options dialog box, or if
you add a new source document or change the current target document. You can
also specify that the diff should be calculated automatically whenever a source or
target file changes if you select If files modified, Stylus Studio runs the diff
operation when it detects changes to a source or target document.
Engine Options
The fields in the Engine Options group box affect how Stylus Studio diffs files.
Use URI to compare namespaces Controls whether or not URIs are used when
comparing namespaces in source and target documents.
document are diffed. There are separate controls for comments, text, entities,
attributes, entity references, and processing instructions.
Performance
Optimize calculation time Provides the set of changes in the shortest time
possible.
Optimize for large documents with few changes Helps speed the diffing of
large (greater than 1MB) documents by folding similar blocks before comparing
nodes. This setting can be used in conjunction with any of the algorithm tuning
settings and is on by default.
How Options are Related to the Menu and the Tool Bar
Settings on the Engine Options page of the Options dialog box affect the default settings
for both the XML Diff menu and tool bar in the XML Diff editor. You can override settings
on the Engine Options page using the menu or the tool bar. To permanently change a
setting, however, make the change on the Engine Options page.
1351
Fields
Added items
Items that appear in the target document but not in the source document.
Removed items
Items that appear in the source document but are not present in the target document.
Changed items
Items that differ in the source and target documents (the text of a node differs, for
example).
Collapsed items with changes
Indicates that there are changes within an item (such as a folder or a node) that is
currently displayed as collapsed. The precise nature of the change becomes visible
once the item is expanded.
Default Colors
Stylus Studio uses these colors by default:
Table 195. Default Colors Used for Diffing Files and Folders
1352
Color
Identifies
Light green
Added items
Light red
Removed items
Light yellow
Change items
Light gray
Changing Colors
To change the default colors:
1.
2.
b.
c.
When the color you want appears in the Color|Solid field, click the Add to
Custom Colors button.
3.
4.
1353
Fields
Sense:X Refresh Interval
Use this dialog box to specify the refresh interval for Sense:X. The default is 10
seconds.
As you edit an XML document, Stylus Studio displays a pop-up menu that lists the
elements and element attributes you can create. Stylus Studio retrieves this
information from the documents schema. The schema can be either at the beginning
of the document, or it can be an external file.
If your document does not have a schema, Stylus Studio does not display the pop-up
list of suggestions.
The information needed for the pop-up menu can change because you edit the internal
DTD or because someone has modified the external schema. When this information
changes, you want to refresh the set of elements and attributes that Stylus Studio
suggests.
The refresh interval is how often you want Stylus Studio to reparse schema data. A
smaller interval means that the data used is more accurate and up to date, but it
requires more CPU processing time. A longer interval means data might be less
accurate and less up to date, but it requires less CPU processing time.
Halt Validation After nnn Errors
Specify the maximum number of errors Stylus Studio can find before it stops trying
to validate an XML document. The default is 50.
Display message box after validation
1354
page.
Example
The following illustrations show how Inline visibility in diagram settings affect the
appearance of the Mode element in the ProductLine complexType.
Hide setting. This is the default setting. (The ProductInfo node is included for context).
1355
displayed:
Fields
Category/Property
The node and, optionally, properties whose inline visibility settings you want to
change.
Inline visibility in diagram
The conditions under which you want to display a property and its values in the XML
Schema diagram. Inline visibility options are:
Hide The property and its value is always hidden. This is the default.
Show The property and its value is always displayed, even if the property does
not have a value.
1356
Show if not empty The property and its value is displayed only if the property
has a value. Properties with a default value (maxOccurs=1, for example) and
properties for which no value has been explicitly set do not appear using this
setting.
Tip If all of a nodes properties have the same show/hide setting (Hide or Show if not empty,
for example), that value is displayed in the Inline Visibility in Diagram field. If no value
is displayed in the Inline Visibility in Diagram field, it means that two or more properties
1357
Fields
XML Schema Documentation Options
Settings that control display and print content and format:
baseURL
The base URL used to resolve diagrams in the XML Schema documentation.
DEFAULT_DOCUMENT_EXT
The extension you want to use for the saved XML Schema documentation. The
default is .html.
externalCSSURL
The external CSS stylesheet used to render the XML Schema documentation. If no
value is specified, Stylus Studio uses internally-declared CSS properties.
linksFile
URL of an XML document that maps the XML Schema's URL to the related
documentation URL for imported and included schemas.
printAllSubTypes
True All sub-types that appear in the XML Instance Representation tables in the
XML Schema documentation are displayed.
True All super-types that appear in the XML Instance Representation tables in
printDiagram
False Does not display schema diagrams in the XML Schema documentation.
print Glossary
You can hide the Glossary by clicking the Printer-friendly Version check box.
Tip
printLegend
You can hide the Legend by clicking the Printer-friendly Version check box.
Tip
printNSPrefixes
True Displays the prefix that matches the namespace of schema components in
XML Instance Representation tables.
False Prefixes of matching namespaces are not displayed.
searchImportedSchemas
True imported schemas are searched for schema components when generating
links and XML Instance Representation tables.
False imported schemas are not searched.
searchIncludedSchemas
True included schemas are searched for schema components when generating
sortByComponent
False Displays the components in the order in which they appear in the schema.
title
1359
The title of the XML Schema documentation. The default, which is not displayed in
the Options dialog box, is XML Schema Documentation.
useJavaScript
Some Internet browsers do not support JavaScript. This option allows you to specify
whether you want Stylus Studio to generate the XML Schema documentation as plain
HTML or as HTML plus JavaScript.
Description
Displays a description of the currently selected option.
1360
Fields
Preferred recursion depth
The level to which you want self-referencing elements in the XML document to
recurse.
Number of elements that triggers a warning
Use this field to set a soft limit on the number of elements Stylus Studio generates.
When this limit is reached, Stylus Studio displays a warning message. You can
continue generating XML, or cancel the generation operation at this time.
Number of Repeating Elements
You use the Number of Repeating Elements fields to control the number of repeating
elements Stylus Studio generates in an XML document based on an XML Schema.
Preferred The number of repeating elements you would like Stylus Studio to
generate. This number is used when its value falls between the minOccurs and
maxOccurs values defined for the element in the XML Schema. If this number is less
than the minOccurs value, the minOccurs number of elements is generated, ensuring
that the resulting document is valid. If this number is greater than the maxcOccurs
value, the maxOccurs number of elements.
Maximum This value is used when the Preferred value is out of the range of the
minOccurs and maxOccurs values (less than minOccurs or greater than maxOccurs), and
Maximum is less than maxOccurs.
Optional Elements and Attributes
Whether or not you want to generate optional elements and attributes specified in the
XML Schema, and whether or not you want to generate comments.
Choices and Substitution Groups
1361
By default, Stylus Studio generates all choices and substitutions specified in the XML
Schema, commenting (//) all but the first one to ensure that the generated XML
document is valid. If you prefer, you can generate
All choices and substitutions, without comments. This will result in an invalid
XML document
1362
Fields
Display predicates in XPath expressions in the canvas
This option allows you to display XQuery predicates in XPath expressions as blocks
on the XQuery canvas. This allows you to manage predicate expressions graphically.
1363
1364
Fields
Render xsl:for-each as a line instead of as a block
This option allows you to render xsl:for-each statements as lines instead of as blocks
to simplify your XSLT diagrams appearance.
Create an empty element for each unlinked node that is required by the associated
schema
Check this box if you want Stylus Studio to create empty elements for nodes in the
source document that are not mapped to nodes in the destination document. Stylus
Studio does this only for nodes that are specified as required by the schema associated
with the source document.
1365
Fields
General
Show Scenario Dialog When On New Document
Check this box if you want Stylus Studio to automatically display the Scenarios
Properties dialog box when you create a new XSLT document.
Save Scenario Meta-Information In The Stylesheet
If you do not save metainformation in the stylesheet, Stylus Studio saves it in the .prj
file for the project the scenario belongs to. If a stylesheet does not belong to a project
and you do not save metainformation in the stylesheet, the information is not saved.
If this is a mapping stylesheet, and you set this option, Stylus Studio also saves
mapping metainformation in the stylesheet. If this option is not set, and the mapping
stylesheet belongs to a project, Stylus Studio saves the mapping metainformation in
the project. If this option is not set, and if the mapping stylesheet does not belong to
a project, Stylus Studio does not save mapping metainformation.
Saving metainformation in a stylesheet is useful because it frees you from having to
re-enter information when you open the stylesheet. However, you might not want a
block of metainformation in your stylesheet, or you might not want to expose path
information in your stylesheet.
Do Not Add Created with Stylus Studio comment at the end of a document
Check this box if you want Stylus Studio to automatically add the Create with Stylus
Studio signature at the end of each new XSLT document.
Debugging
Truncate summaries of debug variable values in Watch and Variables windows to:
The number of characters to which you want to truncate summaries of debug variable
values in Watch and Variable windows that are displayed during debugging. The
default value is 100 characters.
1366
1367
Output Window
The Output Window displays any output from the Java virtual machine. To display the
Output Window, click Output Window
in the Stylus Studio tool bar.
1368
Fields
New Word
Entry field in which you enter the word you want to add to the personal dictionary.
Words in Personal Dictionary
Buttons
Add
Words in the file you wish to import into the personal dictionary must be in a single
column they cannot be tab- or comma-separated.
Export
1369
1370
Preview Window
Preview Window
Stylus Studio uses the Preview window to display processing results for
XQuery
XSLT
XML Pipelines
XML Reports
Back-mapping
You can click output in the Preview window, and Stylus Studio places the cursor in the
line of code in the editor responsible for creating it. For example, if you click a node in an
XML document created using an XML conversion, Stylus Studio places the cursor in the
field and row of the input file displayed in the Custom XML Conversion Editors schema
pane. Back-mapping is supported in the Preview windows Tree and Text views.
The Preview window displays a tab at the bottom for each scenario in which you have
applied a stylesheet or XQuery. Click the tab to view the most recent result for that
scenario.
Buttons
Refresh Preview performs the processing again. You might want to use this button to
quickly see the effect of changes you make to the source document.
Preview in Tree displays the result using a tree representation. Tree view is available
for XML documents only. Back-mapping is available from the Tree view.
Preview in Browser displays the result as it would appear in a Web browser. Backmapping is available only for output in HTML (such as that which might result from
processing an XML document with XSLT, for example). For HTML results based on
1371
XSLT processing, if you click in the result document, Stylus Studio displays the Backmap
Stack window, which lists the XSLT instructions that generated the text or image you
clicked. Stylus Studio also flags the line in the stylesheet that contains the first instruction
in the Backmap Stack window.
Show Profiling Data displays the Stylus Studio Profiler report, if enabled, for XSLT
and XQuery processing. The Profiler report includes overview, call tree, node summary,
and event log statistics. You can backmap from the profiling report to the line of XSLT or
XQuery associated with the statistic. Settings for this report are displayed on the Profiling
Options page of the Scenario Properties dialog box for XSLT and XQuery.
Preview Text displays the raw text of the result. The Text view supports backmapping. You can select and copy text in the Preview Text view.
Export Preview allows you to save the result in a file. It displays the Save As dialog
box.
1372
Processor Mismatch
Processor Mismatch
XML Pipeline is available only in Stylus Studio XML Enterprise Suite.
If the XQuery or XSLT file you add to an XML pipeline uses a different processor (as
specified in that XSLTs or XQuerys scenario properties) than the processor specified for
the XML pipeline in the execution framework, Stylus Studio displays the Processor
Mismatch dialog box. You can
Change the XML pipelines processor setting to the one used by the XQuery or XSLT
Note This dialog box appears only when you add an XQuery or XSLT document to an XML
pipeline by dragging it and dropping it on the XML Pipeline canvas. If you manually
specify the XQuery or XSLT file URL, Stylus Studio defaults to the processor settings
specified for the XML pipeline.
1373
Fields
Processor
Drop-down list that displays available processors for XQuery. The debugging symbol
changes based on whether or not the processor you have selected supports backmapping and debugging. The following table summarizes the available processors
and whether or not they support back-mapping and debugging.
Table 196. Available XQuery Processors
Processor
Supports Back-mapping
and Debugging
Requires Specifying
Server Settings
DataDirect XQuery
No
No
Saxon
Yes
No
TigerLogic XDMS
No
Yes*
Custom
No
No
Whether or not you want to enable the Stylus Studio URI Resolver, which allows the
processor to resolve URIs associated with file systems peculiar to Stylus Studio (like
the file system for XML conversions, for example). This setting is applicable only to
Java-based processors such as Saxon.
Use a default processor
Whether or not you want use the processor you are configuring as the default
processor for all XQuery scenarios. You can always override the default processor
1374
and individual processor settings on the Processor tab of the Scenario Properties
dialog box when you create the scenario.
Custom Processor Settings
Command line, path, and classpath settings for a custom XQuery processor. These
fields are active only if you select Custom in the Processor drop-down list box.
Command line
The command line used to execute the custom XQuery processor. The command line
must show where to use the three arguments: %1 is the XML source file, %2 is the
XQuery, %3 is the result document. For example: myparser -style %2 -source %1 out %3, or myparser %1 %2 %3.
Path
Specifies any path information that is required to run your custom processor and that
is not already defined in your PATH environment variable.
Classpath
Specifies any directories that your processor must access and that are not already
defined in your CLASSPATH environment variable.
1375
Fields
Processor
Drop-down list that displays available processors for XSLT. The debugging symbol
changes based on whether or not the processor you have selected supports backmapping and debugging. The following table summarizes the available processors
and whether or not they support back-mapping and debugging.
Table 197. Available XSLT Processors
Processor
Saxon 9.x
Yes
Java built-in
No
.NET XslTransform
Yes
.NET XslCompiledTransform
No
Microsoft MSXML
No
Microsoft MSXML 4
No
Microsoft MSXML 6
No
Custom
No
Whether or not you want to enable the Stylus Studio URI Resolver, which allows the
processor to resolve URIs associated with file systems peculiar to Stylus Studio (like
the file system for XML conversions, for example). This setting is applicable only to
Java-based processors such as Saxon.
Use a default processor
1376
Whether or not you want use the processor you are configuring as the default
processor for all XSLT scenarios. You can always override the default processor and
individual processor settings on the Processor tab of the Scenario Properties dialog
box when you create the scenario.
Custom Processor Settings
Command line, path, and pathname settings for the custom XSLT processor. These
fields are available only if you select Custom from the Processor drop-down list.
Command line
The command line used to execute the custom XSLT processor. The command line
must show where to use the three arguments: %1 is the XML source file, %2 is the
XSLT stylesheet, %3 is the result document. For example: myparser -style %2 -source
%1 -out %3, or myparser %1 %2 %3.
Path
Specifies any path information that is required to run your custom processor and that
is not already defined in your PATH environment variable.
Classpath
Specifies any directories that your processor must access and that are not already
defined in your CLASSPATH environment variable.
1377
Project Window
To display the Project window, select View > Project from the Stylus Studio menu bar.
Use the Project window to organize files in your XML applications.
You can display just the names of files, or you can display the full path. To toggle this,
right-click in the Project window and click Show Full URL Info in the pop-up menu.
In the Project window, the Other Documents folder contains all open files and documents
that are not included in the currently open project. If all open files and documents are in
the open project, the Other Documents folder does not appear. To close all documents that
are not in the open project, right-click Other Documents and click Close Other
Documents.
1378
Project Wizards
Project Wizards
Stylus Studio includes wizards that create projects from some applications if you have
those applications installed. For example, if you have a source code control application,
the Project from SCC wizard is available.
To display the Project Wizards dialog box, select File > Project > New Project Wizard
from the Stylus Studio menu bar. Click the wizard you want to use, and click OK.
1379
Fields
Properties are organized in the following categories:
Input File read-only information gathered from the input file, and editable properties
that affect XML output. These fields affect the file as a whole when it is converted to
XML. See Input File Properties on page 281.
XML Output URL editable properties that affect XML output, specifically, high-level
XML document properties such as the root element name, namespace, and XML
Schema, if any. See XML Output URL Properties on page 282.
Row Element Name editable properties that affect XML output, specifically, the
name that will be used for each row element and the optional pattern that will be used
to control which rows are converted to XML. See Row Element Name Properties on
page 287.
Field Element Name read only information gathered from the input file, editable
properties that affect XML output, and navigational properties. These properties
affect only fields in a given region of the file when it is converted to XML. See Field
Element Name Properties on page 288.
1381
Fields
Name
1382
Fields
Name
The value associated with the property. Some values are specified by default when
you add the operation to the XML pipeline. The default name, for example, is a
variation of the operation name as shown in the Toolbox pane.
1383
Fields
Name
1384
1385
1386
Proxy Settings
Proxy Settings
Support for Web services is available only in Stylus Studio XML Enterprise Suite.
You use the Proxy Settings page of the Options dialog box to specify the proxy server
settings you want your Web service calls to use. Proxy server settings defined here are
used by each new Web service call you create, but they can be overridden.
Tip If you want to use your PCs default Internet Explorer proxy server settings, click the
Auto-detect button.
Fields
Address
The server name or IP address. If you need to specify a port, separate the port number
from the address with a colon 123.45.67.89:500, for example.
User
The domain names for which you do not wish to use the proxy server settings
(www.stylusstudio.com, for example). Separate multiple entries with semicolons.
Buttons
Auto-detect
Clicking this button populates the Proxy Settings page with the proxy settings defined
for your PC (Control Panel > Internet Options > Connections > Local Area Network
(LAN) Settings > Proxy Settings).
1387
1388
Referenced Schemas
Referenced Schemas
You use the Referenced Schemas dialog box to import or include external XML Schemas
to the current XML Schema including Schema elements in a WSDL document. You use
this feature if you have an externally defined library of complex types that you want to use
in your XML Schema, for example.
Fields
Schemas referenced by this document
The URL, type (import, include, redefine), and namespace of any XML Schemas
referenced by the current XML Schema.
Buttons
Add
Displays the Add References to Schema dialog box, which allows you to define
additional schema references for the current XML Schema.
Remove
Removes the reference to the external XML Schema from the current XML Schema.
Open
1389
Enter your e-mail address in the Email (required) field and your company name in the
Company field. Name and Phone number fields are optional.
2.
3.
Copy/Paste that activation key in the Enter your activation key here field. (The
Company field is pre-filled based on the value you provided in Step 1.
4.
5.
To postpone registration:
If you want to postpone registering your evaluation copy of Stylus Studio, click the
Register Later button. You have 10 days after installation to register.
1390
Rename
Rename
You use the Rename dialog box to rename a user-defined function.
1391
Rename Column
The XML Editor Grid tab is available only in Stylus Studio XML Enterprise Suite
and Stylus Studio XML Professional Suite.
You use the Rename Column dialog box to rename a column in a table displayed in the
Grid tab of the XML Editor. Column names correspond to element and attribute names in
the XML document represented in the grid.
Fields
New Name
1392
Replace
Replace
Use the Replace dialog box to search for text in a document and, optionally, replace it. To
display the Replace dialog box, from the Stylus Studio menu bar, click Replace
or
select Edit > Replace from the Stylus Studio menu.
Fields
Find what
For example, if you specify that you want to search for style, the search engine does
not find instances of stylesheet.
Match case
Finds instances that exactly match the lowercase and uppercase of the letters you
enter.
Regular expression
Finds the text you are looking for only in regular expressions.
Replace In
Specify whether you want to replace the text only a selected portion of the document,
or throughout the entire document.
Search only inside
Indicate whether you want to restrict the search to element tags, element values,
attribute names, and/or attribute values.
Buttons
Find Next
Jumps to the next instance of the string you are searching for.
Replace
1393
Replaces all occurrences of the found text (within the selection or document, as
defined by the Replace In field.
1394
Fields
Command line equivalents for Saxon XQuery settings are shown in parentheses following
the field name where applicable.
Execution mode
Whether you want the Saxon processor to run in basic or schema-aware modes.
Note
Performance settings for document processing. Generally speaking, the Tiny Tree
setting provides superior performance in most cases. For more information on this
topic, see Choosing a Tree Model in the Saxon documentation.
Support XML 1.1
Whether or not to allow XML 1.1 and XML Namespaces 1.1 constructs. This option
must be set if source documents use XML 1.1, or if result documents are to be
serialized as XML 1.1.
Recognize Saxon file extensions and query parameters (-p)
Whether or not you want the Saxon processor to recognize Saxon-specific file
extensions and query parameters in URIs.
Validate source documents using DTD (-v)
Whether or not you want the source document and any documents referenced using
the document() function to be validated against a DTD.
Whitespace stripping
Whether or not whitespace-only text nodes are stripped from the source document.
1395
Ignorable (-signorable) All ignorable whitespace text nodes are stripped from
Schema-aware Settings
These settings are available only if you are using Saxon-SA to execute your XQuery.
1396
Fields
Command line equivalents for Saxon XQuery settings are shown in parentheses following
the field name where applicable.
Execution mode
Whether you want the Saxon processor to run in basic or schema-aware modes.
Tree model
Performance settings for document processing. Generally speaking, the Tiny Tree
setting provides superior performance in most cases. For more information on this
topic, see Choosing a Tree Model in the Saxon documentation.
Start Transformation
Allows you to specify the named template and mode in which you wish to start the
XSLT transformation.
by calling named template (-it) The value of the name= attribute of the
xsl:template element.
in specified mode (-im) The value of the mode= attribute of the xsl:template
element.
Support XML 1.1
Whether or not to allow XML 1.1 and XML Namespaces 1.1 constructs. This option
must be set if source documents use XML 1.1, or if result documents are to be
serialized as XML 1.1.
Suppress warning when running with an XSLT 1.0 stylesheet (-novw)
Suppresses warnings issued when running an XSLT 2.0 processor against an XSLT
1.0 stylesheet.
Stylus Studio User Guide
1397
Whether or not you want the Saxon processor to recognize Saxon-specific file
extensions and query parameters in URIs.
Validate source documents using DTD (-v)
Whether or not you want the source document and any documents referenced using
the document() function to be validated against a DTD.
Treat non-fatal errors as
How you want Stylus Studio to manage non-fatal errors encountered while processing
the XSLT stylesheet:
silent warnings (-w0) Stylus Studio writes error messages to the Output
window, but does not open it automatically. Processing continues.
warnings (-w) Stylus Studio writes error messages to the Output window and
opens the window automatically. Processing continues.
fatal errors (-w2) Stylus Studio writes error messages to the Output window and
opens the window automatically. Processing is interrupted.
Whitespace stripping
Whether or not whitespace-only text nodes are stripped from the source document.
Ignorable (-signorable) All ignorable whitespace text nodes are stripped from
the source documents before any processing, regardless of any xsl:strip-space
declarations in the stylesheet, or any xml:space attributes in the source document.
Whitespace text nodes are ignorable if they appear in elements defined in the
DTD or XML Schema as having element-only content.
All (-sall) All whitespace text nodes are stripped from the source documents
before any processing, regardless of any xsl:strip-space declarations in the
stylesheet, or any xml:space attributes in the source document.
These settings are available only if you are using Saxon-SA to execute your XSLT.
1398
1399
Fields
Protocol
The network protocol to use when sending the Web service call to the WSDL URL.
The default is HTTP.
Properties
You use the fields in the Properties table to specify values for parameters used by the
Web service call. Stylus Studio uses these values when you run the Web service call
scenario.
Table 198. Properties Settings
Name
end point*
Description
The destination of the Web service call
http://www.swanandmokashi.com/HomePage/WebServices/Stoc
kQuotes.asmx,
SOAPAction*
for example.
http://swanandmokashi.com/GetQuotes,
1400
user
password
time out*
Proxy server+
Proxy user+
Description
Proxy password+
The domain names for which you do not wish to use the proxy
server settings (www.stylusstudio.com, for example). Separate
multiple entries with semicolons.
* This field is completed when you select a Web service (using the UDDI Browser,
for example).
+ This field uses default values, if any, provided by the Proxy Settings page of the
Options dialog box.
Client
You use the Client field to specify the type of client you want to use to send the SOAP
request to and receive the SOAP response from the Web service Microsoft .NET, or
Apache Axis.
1401
Fields
Existing Scenarios
Lists the scenarios that have already been defined for the current EDI to XML
Conversion. To view the settings for a different scenario, click the name of that
scenario.
To add a new scenario, click Add. A new scenario is added to the Existing
scenarios list box with a default name.
To copy an existing scenario, click the scenario you want to copy and click Clone.
A new scenario is created with a default name. All other settings are the same as
those of the scenario on which you based the copy.
To rename a scenario, click the scenario and click Rename. The existing name is
highlighted, allowing you to rename it. Press Enter when you are done.
EDI Input (optional)
The absolute path for the file that contains the result of the EDI to XML Conversion
preview. Each time you click Preview Result ( ) to run the EDI to XML
Conversion, Stylus Studio automatically updates the contents of this file (if specified),
and it also displays the result in the Preview window. If you specify an output a file
that does not exist, Stylus Studio creates it.
Use Relative Paths
1402
Allows you to specify input and output files using paths that are relative to the EDI to
XML Conversion. If you plan to move the EDI to XML Conversion to a different
directory than the one to which you save it during development, consider disregarding
this option and using absolute paths to specify input and output files.
Preview Result in an External Application
By default, EDI to XML Conversion results are displayed in the Preview window. You
can use this option to also display the result in the application you specify.
Buttons
Add creates a new scenario.
Clone copies the selected scenario with a new name.
Delete removes the selected scenario.
Rename renames the selected scenario.
1403
Fields
Execution Framework
Validation engine
FO processor
XQuery processor
XSLT processor
When you select an execution framework, Stylus Studio displays default choices for
these fields. You can override them manually if you choose, though the choices you
make can affect Stylus Studios ability to generate code for your XML Pipeline.
1404
Fields
Existing Scenarios
Lists the scenarios that have already been defined for the current stylesheet. To view
the settings for a scenario, click the name of the scenario. Stylus Studio displays the
settings in the General tab.
To add a new scenario, click Add. If Add is not active, type information in the fields
in the General tab and click OK.
To copy an existing scenario, click the scenario you want to copy and click Clone. A
new scenario is created with a default name in the Scenario Name field. All other
settings are the same as those of the scenario on which you based the copy.
To delete a scenario, click it and then click Delete.
Scenario Name
The name of the new scenario. You can use the default name, or create one of your
own. You can specify any characters that are allowed in Windows file names.
Source XML URL
Specify the absolute path for the source XML document you want to apply the
stylesheet to in this scenario. If you want, click Browse
to the right of the field
to select to the path.
Output URL
1405
Optionally specify or select an absolute path for the file that contains the result of
applying the stylesheet. Each time you click Preview XSLT Result, Stylus Studio
automatically updates the contents of this file, as well as displaying the result in the
XSLT Preview window. If you specify a file that does not exist, Stylus Studio creates
it.
Base URL For HTML Links Resolution
Specify the absolute path that Stylus Studio must use to resolve any links in your
XML source document.
Store Paths Relative to XSLT Document Path
Select this option when you want all paths related to this scenario to be relative to the
XSLT document. This is often convenient; however, you might want to always keep,
for example, your XML source files in a particular location. In such a situation, do not
select this option. This allows you to reference your XML files with an absolute path.
You can move your stylesheet to a different directory and the absolute path for the
source file is still correct.
Preview result in an external application
Displays the result in the default application for the output method specified for the
stylesheet. For example, if the output method for the scenario is HTML and if Internet
Explorer is the default application for displaying HTML files, Stylus Studio displays
the resulting HTML in Internet Explorer, as well as in the XSLT Preview window.
Buttons
Add creates a new scenario.
Clone copies the selected scenario except for the scenario name.
Delete removes the selected scenario.
1406
Fields
Existing Scenarios
Lists the scenarios that are defined for the current stylesheet. To view the parameters
for a scenario, click the name of the scenario. Stylus Studio displays the parameters
in the Parameter Values tab.
Name
Parameter name.
Parameter default value
Value of the parameter when you apply the stylesheet in this scenario.
Parameter value is an XPath expression (not a string)
Check box that indicates whether the parameter value is an XPath expression or a
string. The default, which is unchecked, is that the parameter is a string.
1407
Fields
Existing Scenarios
Lists the scenarios that are defined for the current XQuery. To view the post-process
settings for a scenario, click the name of the scenario. Stylus Studio displays the
postprocess settings in the Post-process tab.
Do Not Perform Any Post-processing
This is the default. Stylus Studio does not perform any postprocessing.
Post Process With RenderX XEP
Command line for executing your postprocess. %1 is the input file, which is the result
of applying the stylesheet. %2 is the file that the postprocess generates.
Generated File Extension
File extension you want the postprocessed file to have. For example, .pdf.
Additional Path
Any path information that needs to be defined for postprocess execution and that is
not already defined in your PATH environment variable.
1408
Fields
Existing Scenarios
Lists the scenarios that are defined for the current stylesheet. To view the postprocess
settings for a scenario, click the name of the scenario. Stylus Studio displays the
postprocess settings in the Post-process tab.
Do Not Perform Any Post-processing
This is the default. Stylus Studio does not perform any postprocessing.
Post Process With Apache FOP
Command line for executing your postprocess. %1 is the input file, which is the result
of applying the stylesheet. %2 is the file that the postprocess generates.
Generated File Extension
File extension you want the postprocessed file to have. For example, .pdf.
Additional Path
Any path information that needs to be defined for postprocess execution and that is
not already defined in your PATH environment variable.
1409
Fields
Show Call Tree of Execution Times
Displays the Call Tree section of the Profiler report, which lists the call tree of XSLT
instructions. Duplicate instructions within individual call tree paths are not repeated.
The reports Call column identifies the number of times a given instruction is called
within each call tree.
Show Execution Time by XSL Element
Displays the Node Summary section of the Profiler report, which lists every
instruction that is called by the XSLT code. Instructions are listed only once,
regardless of the number of times they are called. The reports Call column identifies
the number of times an instruction is called.
Show Log of Step-by-Step Execution
Displays the Event Log section of the Profiler report, which lists every instruction that
is executed in every call tree, regardless of the number of times it is called. Displaying
the report with this option selected can, therefore, take a long time. The XSLT
processing time itself is not affected by this report option.
Limit Trace To
Displaying a Profiler report can often take much longer than the time required to
evaluate the XSLT itself. You can use the Instructions and Levels field in the Limit
Trace To group box to limit the number of instructions and/or the depth of the levels
displayed.
Save Raw XML Profiling Data To:
1410
Saves the raw performance data captured by the Profiler to an XML file. Use this
option if you want to create your own reports.
1411
Fields
Existing Scenarios
Lists the scenarios that are defined for the current XQuery. To view the processor
settings for a given scenario, click the name of the scenario.
Processor
Drop-down list that displays available processors for XQuery. The debugging symbol
changes based on whether or not the processor you have selected supports backmapping and debugging. The following table summarizes the available processors
and whether or not they support back-mapping and debugging.
Table 199. Available XQuery Processors
Processor
Supports Back-mapping
and Debugging
Requires Specifying
Server Settings
Saxon 9.x
Yes
No
DataDirect XQuery
No
No
Saxon
Yes
No
TigerLogic XDMS
No
Yes
Custom
No
No
1412
Whether or not you want to enable the Stylus Studio URI Resolver, which allows the
processor to resolve URIs associated with file systems peculiar to Stylus Studio (like
the file system for XMl conversions, for example). This setting is applicable only to
Java-based processors such as Saxon.
Custom Processor Settings
Command line, path, and pathname settings for the custom XQuery processor. These
fields are available only if you select Custom from the Processor drop-down list.
Command line
Command line for executing an external XQuery processor you define. The command
line must show where to use the three arguments: %1 is the XML source file, %2 is the
XQuery, %3 is the result document. For example: myXQprocessor -style %2 -source
%1 -out %3, or myXQprocessor %1 %2 %3.
Path
Specifies any path information that is required to run your custom processor and that
is not already defined in your PATH environment variable.
Classpath
Specifies any directories that your processor must access and that are not already
defined in your CLASSPATH environment variable.
1413
Fields
Existing Scenarios
Lists the scenarios that are defined for the current stylesheet. To view the processor
settings for a scenario, click the name of the scenario. Stylus Studio displays the
processor settings in the Processor tab.
Processor
Drop-down list that displays available processors for XSLT. The debugging symbol
changes based on whether or not the processor you have selected supports back-
1414
mapping and debugging. The following table summarizes the available processors
and whether or not they support back-mapping and debugging.
Table 200. Available XSLT Processors
Note
Processor
Saxon 9.x
Yes
Yes
Yes
Microsoft MSXML
No
Microsoft MSXML 4
No
Microsoft MSXML 6
No
Custom
No
Stylus Studio requires Microsoft .NET Framework 1.1 or 2.0 in order to use the .NET
or MSXML processors.
Use Stylus Studio URI Resolver
Whether or not you want to enable the Stylus Studio URI Resolver, which allows the
processor to resolve URIs associated with file systems peculiar to Stylus Studio (like
the file system for XML conversions, for example). This setting is optional only with
Java-based processors such as Saxon.
Custom Processor Settings
Command line, path, and pathname settings for the custom XSLT processor. These
fields are available only if you select Custom from the Processor drop-down list.
Command line
The command line used to execute the custom XSLT processor. The command line
must show where to use the three arguments: %1 is the XML source file, %2 is the
XSLT stylesheet, %3 is the result document. For example: myparser -style %2 -source
%1 -out %3, or myparser %1 %2 %3.
Path
Specifies any path information that is required to run your custom processor and that
is not already defined in your PATH environment variable or in the default Path in the
External XSLT options page.
Stylus Studio User Guide
1415
Specifies any directories that your processor must access and that are not already
defined in your CLASSPATH environment variable or in the default Classpath in the
Custom Processor options page.
1416
Fields
Existing Scenarios
Lists the scenarios that have already been defined for the current XQuery. To view the
settings for a different scenario, click the name of that scenario.
To add a new scenario, click Add. A new scenario is added to the Existing
scenarios list box with a default name.
To copy an existing scenario, click the scenario you want to copy and click Clone.
A new scenario is created with a default name. All other settings are the same as
those of the scenario on which you based the copy.
To rename a scenario, click the scenario and click Rename. The existing name is
highlighted, allowing you to rename it. Press Enter when you are done.
Main Input (optional)
The XML against which you want to run the XQuery. This can be an existing XML
document, or an XML document Stylus Studio creates on the fly using an XMl
conversion to convert a text file, like EDI, to XML. See Other Ways to Convert Files
to XML on page 216 for more information.
Output URL (optional)
1417
Optionally specify or select an absolute path for the file that contains the result of the
XQuery preview. Each time you click Preview Result to run the XQuery, Stylus
Studio automatically updates the contents of this file, and it also displays the result in
the Preview window. If you specify an output a file that does not exist, Stylus Studio
creates it.
Use Relative Paths
Allows you to specify input and output files using paths that are relative to the
XQuery. If you plan to move the XQuery to a different directory than the one to which
you save it during development, consider disregarding this option and using absolute
paths to specify input and output files.
Preview Result in an External Application
By default, XQuery results are displayed in the Preview window. You can use this
option to also display the result in the default application for the output method
specified for the XQuery. For example, if the output method for the scenario is HTML
Stylus Studio displays the resulting HTML in a web browser like Internet Explorer,
as well as in the Preview window.
Buttons
Add creates a new scenario.
Clone copies the selected scenario with a new name.
Delete removes the selected scenario.
Rename renames the selected scenario.
1418
Fields
Variable Name
The expression associated with the variable. You can enter a value in this field.
1419
Fields
Show Call Tree of Execution Times
Displays the Call Tree section of the Profiler report, which lists the call tree of
XQuery instructions. Duplicate instructions within individual call tree paths are not
repeated. The reports Call column identifies the number of times a given instruction
is called within each call tree.
Show Execution Time by XQuery Instruction
Displays the Node Summary section of the Profiler report, which lists every
instruction that is called by the XQuery code. Instructions are listed only once,
regardless of the number of times they are called. The reports Call column identifies
the number of times an instruction is called.
Show Log of Step-by-Step Execution
Displays the Event Log section of the Profiler report, which lists every instruction that
is executed in every call tree, regardless of the number of times it is called. Displaying
the report with this option selected can, therefore, take a long time. The XQuery
processing time itself is not affected by this report option.
Limit Trace To
Displaying a Profiler report can often take much longer than the time required to
evaluate the XQuery itself. You can use the Instructions and Levels field in the Limit
Trace To group box to limit the number of instructions and/or the depth of the levels
displayed.
Save Raw XML Profiling Data To:
Saves the raw performance data captured by the Profiler to an XML file. Use this
option if you want to create your own reports.
1420
1421
Any third-party validation engine supported by Stylus Studio (XSV, for example)
Any custom validation engine specified in the Custom Validation Engines page of the
Options dialog box
If you use the built-in validation engine, you can also specify the XML Schema against
which you want the XML document to be validated.
Fields
Validate the query result
Whether or not you want to validate the result of the XQuery processing.
Use built-in validator
Whether or not you want to use Stylus Studios built-in validation engine.
Validate against these schemas
The XML Schema against which you want the XML document to be validated. You
can specify XML Schema for validation only if you use the Stylus Studio built-in
validation engine.
Use custom validation engine
Whether or not you want to use a third-party or other custom validation engine to
validate the result of the XQuery processing. You can choose a third-party validation
engine supported by Stylus Studio or any custom validation engine defined on the
Custom Validation Engines page of the Options dialog box.
1422
Any third-party validation engine supported by Stylus Studio (XSV, for example)
Any custom validation engine specified in the Custom Validation Engines page of the
Options dialog box
If you use the built-in validation engine, you can also specify the XML Schema against
which you want the XML document to be validated.
Note Validation is always performed before any post-processing you specify on the Postprocess tab.
Fields
Validate the stylesheet result
Whether or not you want to validate the result of the XSLT processing.
Use internal validator
Whether or not you want to use Stylus Studios built-in validation engine.
Validate against these schemas
The XML Schema against which you want the XML document to be validated. You
can specify XML Schema for validation only if you use the Stylus Studio built-in
validation engine.
Use custom validation engine
Whether or not you want to use a third-party or other custom validation engine to
validate the result of the XSLT processing. You can choose a third-party validation
engine supported by Stylus Studio or any custom validation engine defined on the
Custom Validation Engines page of the Options dialog box.
1423
Segment Definition
The EDI to XML Conversions module is available only in Stylus Studio XML
Enterprise Suite.
You use the Segment Definition dialog box to add a segment definition to the EDI
structure associated with your EDI to XML Conversion. The segment definition resides
in the SEF file for your EDI to XML Conversion.
Fields
Segment Name
The name you want to give to the segment. Names are always created in upper case.
Description
1424
Buttons
Use the Add New button to display the Open dialog box, from which you can navigate
to the file system where the XML Schema you want to use is written.
Use the Remove button to remove the association of the XML Schema with the
Validate node.
1425
1426
Fields
Property
The configuration property to be used with the selected DataDirect XML Converter.
Custom XML conversion definitions do not display configuration properties.
See Chapter 4, XML Converters Properties, in the DataDirect XML Converters
Users Guide and Reference for complete properties reference information for all
DataDirect XML Converters. information. Documentation for DataDirect XML
Converters is available:
In the \doc folder for DataDirect XML Converters where you installed Stylus
Studio \components\XML Converters for .NET\doc, for example
Value
The converter URL for the DataDirect XML Converter or custom XML conversion
definition you selected.
1427
1428
Fields
Property
The full name of the XML Converters property, followed by the name as it appears
in the converter:EDI URI scheme.
See Chapter 4, XML Converters Properties, in the DataDirect XML Converters
Users Guide and Reference for complete properties reference information for all
DataDirect XML Converters. information. Documentation for DataDirect XML
Converters is available:
In the \doc folder for DataDirect XML Converters where you installed Stylus
Studio \components\XML Converters for .NET\doc, for example
Value
The URI that is used by the DataDirect XML Converters engine when you preview
an EDI to XML Conversion. This field is read-only; changes to it are made using the
Value field in the Property table.
1429
1430
Set Classpath
Set Classpath
You use the Set Classpath dialog box to specify a classpath for various Stylus Studio
modules. Examples include the classpath for:
Note The title of this dialog box varies based on the context in which it appears. The
Fields
Locations
) button.
2.
To search for JAR files, click the browse JAR files button (
).
1431
Stylus Studio displays the Browse for JAR Files dialog box.
).
1432
Choose the JAR file or folder you want to add to the classpath and click OK.
The file or folder is added to the end of the list. Stylus Studio searches the classpaths
in the order they appear in the Locations list box.
Set Classpath
4.
To change the order of a particular file or folder, select it and use the up and down
arrows to change its order.
5.
1433
Fields
Row Element Name
Specifies the name you want to use for rows in the file to be converted to XML that
match the pattern you specify in the Match Pattern field.
Match Pattern
The regular expression you want to use to match rows from the non-XML file you are
converting to XML. To learn more about regular expression syntax, visit
http://www.boost.org/libs/regex/doc/syntax.html.
1434
Shortcut Keys
Shortcut Keys
To specify keyboard shortcuts, select Tools > Keyboard from the Stylus Studio menu bar.
The Shortcut Keys dialog box allows you to specify a keyboard shortcut for a Stylus
Studio task.
Fields
Select a macro:
Displays a list of over 100 actions you might perform while using Stylus Studio.
Some are menu selections and others are item and button selections. For example:
File > Project > Add Document to Project
XML : Tree Editing : Add Attribute
Click the macro for which you want to specify a keyboard shortcut.
Description
Displays the keyboard shortcut, if any, defined for the selected macro.
Buttons
Create Shortcut
Click a macro and then click Create Shortcut to define the keyboard shortcut. The
Assign Shortcut dialog box appears. See Assign Shortcut on page 1209.
Remove
To delete a shortcut, click the macro for which the shortcut is defined. In the Assigned
shortcuts field, click the shortcut you want to delete. Click Remove.
Reset All
1435
Fields
Provider
Information required for Stylus Studio to connect to your source control server.
Local Project Path
Local directory to which you copied the files that are under source control. If you
move these files, you must specify the new directory here.
1436
Spelling
Spelling
You use the Spelling dialog box actively spell check an XML document. This dialog box
appears when you select Tools > Check Spelling from the menu, even if the Spell Checker
is disabled for the current editor type (Tools > Options > General).
In addition to checking the spelling in the current document, you use the Spelling dialog
box to
Replace words
Fields
Misspelled Word
Displays the misspelled word identified by the Spell Checker. (The misspelled word
is also selected in the document editor.)
Replace With
Allows you to specify an alternative for the misspelled word. Type your own word, or
select a work from the Suggestions field.
When you type your own word, the Add button becomes active, allowing you to add
the new word to your personal dictionary.
Tip
Alternatives
Alternative suggestions to the misspelled word. The words in this field are from a
merged version of the Spell Checkers standard dictionary and your personal
dictionary entries.
Buttons
Ignore
Ignores the word currently identified as misspelled and continues spell checking the
document.
Ignore All
Ignores all occurrences of the word currently identified as misspelled and continues
spell checking the document.
Replace
1437
Replaces the word currently identified as misspelled with the word displayed in the
Replace With field and continues spell checking the document.
Replace All
Replaces all occurrences of the word currently identified as misspelled with the word
displayed in the Replace With field and continues spell checking the document.
Personal Dictionary
Add Adds words identified as misspellings to the personal dictionary and continues
spell-checking the document.
Edit Displays the Personal Dictionary Editor dialog box, which allows you to edit
the contents of the personal dictionary.
1438
Fields
New Region Type
Used to specify the type of the region you are creating. Choices are:
Fixed-width
No-output
Begin New Region
The point in the file at which you want to create the new region. Choices are relative
to the cursors current position in the file:
If the .conv file you are creating will be used with different input files, it is possible
that the line lengths could vary from file to file, changing the byte offset. Consider
using the row setting (the default) for the Begin New Region property in this case.
1439
Stylus Studio
Use Stylus Studio to develop an XML application. To get an overview of the tool, see
Getting Started with Stylus Studio on page 1, or take a look at our online videos to get
a virtual view of Stylus Studio modules in action.
If you would rather just get started, the following shortcuts might get you pointed in the
right direction. To create a
XML document, select File > New > XML Document. To open an XML document,
select File > Open and navigate to the document you want to open.
Custom XML conversion, select File > New > Custom XML Conversion
Relational data source, right-click the Relational DB icon in the File Explorer window
and select New Server.
Web Service call, select File > New > Web Service Call.
Support for relational databases and XQuery is available only in Stylus Studio
XML Enterprise Suite and Stylus Studio XML Professional Suite. Support for XML
Pipelines, XML reports, Web services, and the Custom XML Conversions
module is available only in Stylus Studio XML Enterprise Suite.
To debug an XQuery document, XSLT stylesheet, Java file, open the file you want to
debug.
If you want, you can create a project to help you organize the files in your application. In
the Project window, right-click to display the project management shortcut menu.
1440
Stylus Studio
Defining an XML Schema Using the Diagram Tab Getting Started on page 66
Composing Web Service Calls on page 943
1441
Buttons
Latest Version
This button becomes active if a newer release version of Stylus Studio is available.
Latest Beta
This button becomes active if a newer beta version of Stylus Studio is available.
Close
1442
Fields
Choose OASIS Text-mode Catalog File
The text catalog you want to convert to XML format. Type the name, or use the
Browse button.
1443
Toolbox Pane
XML Pipeline is available only in Stylus Studio XML Enterprise Suite.
The Toolbox pane contains icons that represent the nodes you can add to an XML
pipeline. To use a tool from the Toolbox pane, simply drag the icon associated with the
node you want to add to your XML pipeline, and drop it on the XML pipeline canvas. The
node is added to the XML pipeline, and its properties are displayed in the Properties
window.
To specify properties for input ports and output ports, you must select the port explicitly.
Properties for ports are not displayed with the properties for the node with which they are
associated.
1444
Fields
Host
The URI of the machine on which the TigerLogic XDMS server is installed.
Port
User
Password
1445
Type Derivation
You use the Type Derivation dialog box to specify the base type from which you want to
derive the type you are currently defining in the XML Schema Editor Diagram tab. You
can select from types defined by World Wide Web Consortium (W3C) XML Schema, as
well as from any types defined in the XML Schema you are redefining.
1446
Fields
UDDI Registry
The string you want to use to search the registry for available Web services (stocks
or weather, for example).
Max Rows
The maximum number of rows you want the query to return and display in the Result
field.
Search By
Whether you want to search the UDDI registry by the Web service provider name
(Provider), or by Web service name (Service). Web service name is the default.
Result
The result of the query entered in the Query field when the query is run.
WSDL URL
The WSDL URL exposed by the Web service you select from the Result field.
1447
Value
You use the Value dialog box in the XQuery and XSLT mapper to specify the text value
you want to associate with a target structure element or attribute. This dialog box appears
when you select Set Text Value from the element or attribute shortcut menu in the target
structure.
In addition, you use the Value dialog box in the XSLT mapper to specify the value you
want to associate with an input port in an XSLT operation block, XPath or Java function
block, or logical operator. For example, you might use the Value dialog box to specify the
value for an xsl:value-of operation.
XQuery support is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
1448
Variables
Variables
During debugging, click Variables
in the Stylus Studio tool bar to display the
Variables window. This button is active only when processing has been suspended.
For Java classes, Stylus Studio displays
Local variables that are defined at that point in the processing and their values.
A special variable named this. The this variable represents the object being
processed. It allows you to drill down and obtain additional information.
For stylesheets, Stylus Studio displays a path that shows which node in the stylesheet was
being processed when processing was suspended.
1449
1450
Watch
Watch
During debugging, click Watch
in the Stylus Studio tool bar to display the Watch
window. Use the Watch window to monitor particular variables.
Enter the names of the variables you want to watch. You can enter as many as you like. In
your Java program, you can double-click a symbol and drag it to the Watch window to
enter it as a variable you want to watch. When Stylus Studio suspends processing, it
displays the current values for any variables listed in the Watch window.
Another way to obtain the value for a variable is to hover over the symbol in your Java
program or stylesheet. Stylus Studio displays a pop-up box that contains the current value.
During XSLT debugging, you can enter XPath expressions in the Watch window fields.
Stylus Studio uses the current context to evaluate these expressions, and displays the
results with the same kind of interface Stylus Studio uses for nodeList and node variables.
1451
1452
Fields
WSDL URL
The URL of the Web Service Description Language (WSDL) made available by a
given Web service. You can type a URL, use the Browse button, or use the UDDI...
button to search the Universal Discovery, Description, and Integration (UDDI)
registries.
Operations
The operations exposed by the WSDL identified in the WSDL URL field. When you
select an operation, the parameter names and types and the SOAP request associated
with that operation are displayed in the right side of the Web service call composer.
Name
The SOAP request parameter value. You can enter a value in this field, or directly in
the SOAP request XML.
1453
WSDL Editor
The WSDL Editor is available only in Stylus Studio XML Enterprise Suite.
You use the WSDL (Web Services Description Language) Editor to review and edit
WSDL documents in Stylus Studio. The WSDL Editor consists of a Diagram tab, which
itself is made up of
A diagram pane
A text pane
A Properties window, which can be opened and closed using the View > Properties
choice on the Stylus Studio menu, displays properties for the selected WSDL or XML
Schema element.
1454
1455
1456
1457
Buttons
Insert Row Before Inserts a new row before the current row.
Insert Row After Inserts a new row after the current row.
Delete Row Deletes the current row.
Move Up Moves the current row or table up in the diagram.
Move Down Moves the current row or table down in the diagram.
Add Nested Table Adds a nested table under the current row.
Add Attribute Column Adds an attribute column to the current row.
Add Element Column Adds an element column to the current row.
Rename Column Allows you to rename the current column.
Delete Column Deletes the current column.
1458
1459
1460
To add a node, select a node that is already in the DOM tree, and then click the button for
the type of node you want to add. Stylus Studio adds the new node relative to the node
you selected.
1461
Buttons
Indent XML Tags inserts tabs throughout the XML document if the document is wellformed XML. If it is not well formed, clicking this button does nothing.
Validate Document validates your XML document against its DTD.
Change Font changes the font of the text display in Stylus Studio. This change affects
only the Stylus Studio display. Beyond personal preference, this is useful for localization.
The fonts that are available are the fonts that can display the characters in your XML file.
Open Schema opens the schema, if there is one, for the XML document.
1462
2.
1463
contain.
New Comment adds a new comment node. Enter the comment.
New Processing Instruction adds a new processing instruction. Specify a name for
the processing instruction, and then specify the instruction.
New Entity Reference adds a new reference to an entity defined in the schema for this
document.
1464
Start the process of adding the nodes that make up your XML pipeline. You can do
this by dragging an XQuery or XSLT document, for example, from the Project
window and dropping it onto the canvas, or by dragging an icon representing the
operation you want to add from the Toolbox pane and dropping it onto the canvas.
1465
Fields
Execution Framework
Slider that controls the default zoom setting for new XML Pipelines.
Edge Style
Drop-down list that displays available styles for XML Pipeline edges. The default is
Line.
Degubbing
The length at which you want to truncate summaries of debug variable values
displayed in the Watch and Variables debug windows.
1466
Navigation Bar
The navigation bar contains glyphs that identify the hierarchy of the component in your
report that currently has the editors focus. You can use the navigation bar to move the
focus from one area of the report to another; similarly, the glyphs in the navigation bar
change when you place the text cursor in a different part of the report.
Figure 602 shows that the dynamic value within a table cell currently has focus. All
components occur within the body component; the glyph for the body component always
appears first.
1467
Toolbar
The buttons in the XML Publisher toolbar let you specify formatting for the component
or piece of text in the canvas that has focus. It also lets you preview the report and generate
code for it.
1468
Buttons
The buttons on the data sources panel let you add and remove data sources, choose the
data source you want to use as the default, create a relationship, and open a source
document in Stylus Studio.
Fields
Namespace/URI
If the document you have selected as a source uses a namespace prefix, Stylus Studio
displays the prefix and the URI at the bottom of the data sources panel. You can
change the value in the Namespace field and use the renamed prefix in the XPath
expressions you define in the Properties window.
1469
1470
Figure 605.
1471
HTML (XHTML+CSS)
PDF (XSL-FO)
1472
Tree Displays a tree representation of the XML Schema. XML Schema Editor Tree
Tab.
Fields
Properties
The Properties window displays the properties for the selected node in the diagram.
Click a node to view its properties. The properties that appear vary according to the
node you select. See About XML Schema Properties on page 648.
Buttons
Indent XML Tags inserts tabs throughout the XML document if the document is wellformed XML. If it is not well formed, clicking this button does nothing.
Check Well-formed verifies that the document is well-formed XML.
1473
not, Stylus Studio displays a message that indicates the location and cause of each error.
Change Font changes the font of the text in the XML Schema Editor diagram pane.
Beyond personal preference, this is useful for localization. The fonts that are available are
the fonts that can display the characters in your XML file.
Back returns the XML Schema diagram to the previous page.
Forward reopens the previously viewed page.
Display Definition Displays the definition of the currently selected node on a new
page within the diagram.
Go to Definition Scrolls to the definition of the currently selected node within the
current view of the XML Schema.
Simplify Diagram Hides annotation, documentation, simpleContent,
complexContent, and anonymous complexTypes from the diagram.
Add Allows you to add a new node to the XML Schema.
Insert Before Allows you to add a new node to the XML Schema prior to the
currently selected node.
Insert After Allows you to add a new node to the XML Schema after the currently
selected node.
QuickEdit Automatically performs basic editing operations (changing a sequence
node to a choice or any node, for example); available operations change based on the
currently selected node.
Move Down Moves the selected node down one position on the current branch.
Move Up Moves the selected node up one position on the current branch.
1474
1475
Buttons
Save Documentation allows you to save the report in a file. By default, the report is
saved with a .html extension, but you can change the default in the Options dialog box.
(You can also change the extension at the time you save the report in the Save As dialog
box.) See Options - Module Settings - XML Schema Editor - Documentation on
page 1358 for more information.
Options displays a dialog box that allows you to set properties that determine some
of the contents and behavior of the HTML file. See Options - Module Settings - XML
Schema Editor - Documentation on page 1358 for more information.
As you click links in the report, Stylus Studio maintains a history of the links you
follow. Back returns the focus to the previously followed link.
Forward returns the focus to the link you followed from this link.
Stop allows you to halt Stylus Studio processing of the generated HTML report.
Report Contents
The report contains
A title, which you can customize (the default title is XML Schema Documentation).
Information about the XML Schema document properties, such as its target
namespace and any declared namespaces.
A legend that describes the graphical conventions used to display the XML Schema
document in the report. The legend uses a fictitious type declaration for example
purposes.
1476
Tip
1477
Fields
Properties
The Properties window displays the properties for the selected DOM tree node. Click
a node in the DOM tree to view its properties. The properties that appear vary
according to the type of node you select. See About XML Schema Properties on
page 648.
To edit properties in the Properties window, double-click the value you want to
change. For some properties, Stylus Studio displays a shortcut menu of possible
values. Double-click the value you want. For other properties, you must type the new
value, and press Enter.
1478
Click the Schema node or a model group node (all, any, choice, or sequence)
and then click this button to define a new element as a child of the selected node.
New Attribute Definition
Click the Schema node, a complex type node, or an attribute group node, and
then click this button to define an attribute name. This attribute is associated
with the node that was selected when you clicked New Attribute.
New Group
Click the Schema node, a complex type node, or a model group node, and then
click this button to define a new model group. The group can contain new
definitions of elements, references to previously defined elements, nested
definitions of groups of elements, or references to groups of elements.
New Attribute Group
Click the Schema node or a complex type node, and then click this button to
define a new attribute group. The group can contain new definitions of
attributes, references to previously defined attributes, definitions of new
attribute groups, or references to attribute groups.
1479
Click a complex type node or a group node, and then click this button to specify
a model group. A model group specifies the occurrence rules for the elements
that you add as children of the model group node. Specify one of the following
values:
all specifies that each element must appear exactly zero or one time. The
elements can appear in any order. In an instance document, the children of
the group or complex type can include 0 or 1 instance of each element.
choice specifies that exactly one element can be present, and there must be
sequence specifies there must be exactly one instance of each element and
the elements must appear in the order in which they are specified in the
schema. In an instance document, each element must appear once. They
must have the same order they have in the schema.
Another value you can specify is any. When you specify any, you do not
add any element definitions or references to elements. As the name
implies, any element can appear any number of times.
New Simple Type
Click the Schema node, an element node, an attribute node, a list node,
or a union node, and then click this button to define a simple type. An
element that contains only data is a simple type. Attributes are always
simple types.
New Complex Type
Click the Schema node or an element node, and then click this button to define
a complex type. An element that contains anything more than raw data is a
complex type.
New Restriction
Click a simple type node and then click this button to specify the base type for
the simple type.
New Extension
Click a content node and then click this button to specify the base type that this
complex type extends.
1480
1481
Click a model group node (all, any, choice or sequence), and then click this
button to specify an element that the parent element of the model group node
can contain.
New Reference to Attribute
Click a complex type node, and then click this button to add a reference to an
attribute.
New Reference to Group
Click a complex type node or a model group node (all, any, choice,
sequence), and then click this button to add a reference to a group.
New Reference to Attribute Group
Click a complex type node or an attribute group node, and then click this button
to add a reference to an attribute group.
New Annotation
Click any node to add an annotation node. An annotation node indicates the
beginning of some documentation.
New Documentation
Click an annotation node to add documentation. You can include text, a URL, a
file path.
New Text
1483
XPath Editor
XML Publisher is available only in Stylus Studio XML Enterprise Suite.
You use the XPath Editor dialog box to write the XPath expressions you want to use for
the XPath sub-property. Together, the Context and XPath sub-properties let you define the
conditions under which you want to, say, display a value or apply a given formatting
characteristic. You can use the Color propertys Context and XPath sub-properties to
format text based on the value returned by an XPath expression format all R rated
movies in videos.xml using the color red, for example. (See Example: Using Context and
XPath Sub-Properties to Format Text for an illustration of this technique.)
1484
A query pane, in which you enter the XPath you want to execute against the current
document
A results pane, which shows the results from the query after you execute it. Results
are shown as a number of hits and include the type of XML tag and value of each hit.
When you click on a returned node, Stylus Studio moves the cursor in the XML
document to the source node for the returned node.
A namespace pane, which allows you to redefine the namespace prefix to be used in
the query. The namespace pane is not displayed by default.
You can create up to sixty-four queries for a single XML document; each is saved on its
own tab, which appears at the top of the query pane. To see a different query, click the
appropriate tab. To delete a query, click the Delete Query button.
Tool Bar
New XPath Query creates a new query tab in the XPath Query Editor.
Execute Query executes the current query in the XPath Query Editor.
Open result in a new XML document creates a new XML document based on the
1485
xsl:apply-template
xsl:choose
xsl:if
xsl:for-each
xsl:value-of
1486
XQuery Editor
XQuery Editor
XQuery support is available only in Stylus Studio XML Enterprise Suite and
Stylus Studio XML Professional Suite.
You use the XQuery editor to work with XML files in Stylus Studio.
1487
Fields
Create Scenario
A scenario allows you to preview the results of applying an XQuery. Scenario settings
include the name of an XML source document, the values of any parameters in the
XQuery script, and the type of performance metrics you want Stylus Studio to
capture, if any. XQuery scenarios are optional.
To create a scenario, click
to the right of the scenario name field. After you create
the first scenario, the name of the current scenario appears in this field.
Click the down arrow to select a previously defined scenario. Click Preview Result
to apply the XQuery in the context of the selected scenario. Stylus Studio
displays the results of applying the XQuery in the Preview window.
Buttons
Preview Result applies the XQuery in the context of the current scenario.
Change Font changes the font of the text display in Stylus Studio. This change affects
only the Stylus Studio display. Beyond personal preference, this is useful for localization.
The fonts that are available are the fonts that can display the characters in your XML file.
displays the Scenario Properties dialog box. Use this dialog box to define a new
scenario, update the settings for a scenario, or view information about a scenario.
1488
1489
How to Map
To map a source document node to an existing target structure node, drag and drop the
source element using the left mouse button.
To use a source document node to create a new node on the target structure, drag and drop
the source element using the right mouse button and select one of the following operations
from the shortcut menu:
Fields
Create Scenario
A scenario allows you to preview the results of applying an XQuery. Scenario settings
include the name of an XML source document, the values of any parameters in the
XQuery script, and the type of performance metrics you want Stylus Studio to
capture, if any. XQuery scenarios are optional.
To create a scenario, click
to the right of the scenario name field. After you create
the first scenario, the name of the current scenario appears in this field.
Click the down arrow to select a previously defined scenario. Click Preview Result
to apply the XQuery in the context of the selected scenario. Stylus Studio displays
the results of applying the stylesheet in the Preview window.
Source file name
1490
Click here to change the name of the source XML document you want to use to
perform the mapping. When the mapping is complete, you will have a stylesheet that
you can apply to documents that have the same schema as this document.
Destination file name
Click here to change the name of the target XML document you want to use to
perform the mapping. When the mapping is complete, you will have a stylesheet that
generates XML documents that have the same schema as this document.
Buttons
Preview Result runs the XQuery. Information from the current scenario is used to run
the XQuery if a scenario has been created.
Change Font changes the font of the text display in Stylus Studio. This change affects
only the Stylus Studio display. Beyond personal preference, this is useful for localization.
The fonts that are available are the fonts that can display the characters in your XML file.
displays the Scenario Properties dialog box. Use this dialog box to define a new
scenario, update the settings for a scenario, or view information about a scenario.
Add Source Schema displays the Open dialog box and lets you select a source document
for the XQuery mapper. Stylus Studio uses the first document you select as the default
source XML for the scenario. You can use multiple sources in the XQuery mapper.
Set Target Schema displays the Open dialog box so you can select a target document for
the XQuery mapper. You can create a target document from scratch right click in the Set
Target Schema canvas and select Create Root Element.
1491
1492
xsl:choose
xsl:choose
You use the xsl:choose dialog box to
Fields
xsl:when Conditions
Just type the attributes value. For example, if you want this xsl:when expression,
<xsl:when test="books/book/authors/author">, you would just type
books/book/authors/author in the entry field. Note the absence of the quotation
marks.
Include xsl:otherwise
A check box used to indicate whether or not you want to include the xsl:otherwise
element in the xsl:choose instruction. The xsl:otherwise element is included in the
xsl:choose instruction by default when you create xsl:choose in the XSLT mapper.
If you deselect this check box, the xsl:otherwise port (the square port) is removed
from the xsl:choose block (and from the XSLT source).
1493
Fields
Create Scenario
Click here to change the name of the source XML document you want to use to
perform the mapping. When the mapping is complete, you will have a stylesheet that
you can apply to documents that have the same schema as this document.
Destination file name
Click here to change the name of the target XML document you want to use to
perform the mapping. When the mapping is complete, you will have a stylesheet that
generates XML documents that have the same schema as this document.
1494
Buttons
Preview Result applies the stylesheet in the context of the current scenario.
Scenario Properties displays the Scenario Properties dialog box. Use this dialog
box to define a new scenario, update the settings for a scenario, or view information about
a scenario.
Open XML From Scenario opens the XML document specified as the source
document in the current scenario. Stylus Studio displays the source document in the XML
editor.
Display Preview Window toggles the display of the XSLT Preview window.
1495
Fields
XSLT Encoding
Specifies the encoding for the stylesheet. The default is UTF-8. Click the down arrow
to display a list of encodings that you can choose.
Output method
Specifies the format for a document that is the result of applying this stylesheet. The
default is HTML. Click the down arrow to select from html, xml, text, or unspecified.
When unspecified is selected, and there is no xsl:output instruction in the stylesheet,
the output method is XML.
When the output is XHTML, specify XML as the Output method. Stylus Studio
displays the result as rendered HTML in the Preview in Browser view of the XSLT
Preview window.
Output Encoding
Specifies the encoding for a document that is the result of applying this stylesheet.
The default is UTF-8. Click the down arrow to display a list of encodings that you can
choose.
Indent
This read-only field displays the parameters in your stylesheet, and their default
values. You can right-click a parameter to jump to its definition in the stylesheet.
The parameter information also specifies the source file that defines the parameter.
This is especially helpful when you have a chain of included or imported stylesheets.
In this situation, the source file that defines a parameter might not be obvious.
1496
1497
Fields
Create Scenario
Buttons
Indent XML Tags inserts tabs throughout the XSLT stylesheet if the stylesheet is well-
formed XML. If it is not well formed, clicking this button does nothing.
Change Font changes the font of the text display in Stylus Studio. This change affects
only the Stylus Studio display. Beyond personal preference, this is useful for localization.
The fonts that are available are the fonts that can display the characters in your XML file.
Add a New Template creates a new template. Specify the match pattern in the Match
field.
Delete the Template deletes the selected template.
Preview XSLT Result applies the stylesheet in the context of the current scenario.
Scenario Properties displays the Scenario Properties dialog box. Use this dialog
box to define a new scenario, update the settings for a scenario, or view information about
a scenario.
1498
document in the current scenario. Stylus Studio displays the source document in the XML
editor.
Display Preview Window toggles the display of the XSLT Preview window.
Source Tree toggles the display of the tree representation of the XML source
document specified in the current scenario. Expand and collapse the tree as needed.
Double-click a node to create a template that matches that node. Stylus Studio displays a
check mark next to nodes that have matching templates.
Full Source mode displays the entire stylesheet.
Template mode displays the template you select. Click the down arrow in the upper
right corner of the XSLT editing pane to display a list of templates.
1499
1500
Symbols
Symbols
.conv files
default Stylus Studio module and 92
.dff files
default Stylus Studio module and 92
.dtd files
default Stylus Studio module and 92
.java files
default Stylus Studio module and 92
.NET
generating C# code for an XML pipeline 1069
how to generate C# code for an XML pipeline 1073
.prj files
default Stylus Studio module and 92
.rdbxml files
default Stylus Studio module and 92
.wsc and .wscc files
default Stylus Studio module and 92
.xml files
default Stylus Studio module and 92
.xquery files
default Stylus Studio module and 92
.xsd files
default Stylus Studio module and 92
.xsl files
default Stylus Studio module and 92
.zip files
using as XQuery data sources 862
using as XSLT data sources 862
A
ActiveX controls
xqDoc and 916
ancestor axis 729
ancestor-or-self axis 733
AND operator 741
annotating
1501
1502
setting 148
XQuery debugging and 891
bookstore.xml 703
boolean data type properties 292
boolean() function 742
Booleans
converting operands to 742
expressions 741
functions 742
breakpoints
in stylesheets 552
in XQuery documents 888
byte data type properties 295
C
C Rules for Octal and Hex data type property 305
C#
compiling code generated from XQuery 465, 942
deploying code generated from XQuery 942
deploying code generated from XSLT 465
generating C# code for an XML pipeline 1069
generating code from XQuery 938
generating code from XSLT 460
how to generate C# code for an XML pipeline 1073
restrictions for generated code for XML Pipelines 1070
call stack
displaying the Call Stack window in the XQuery editor 890
canonical XML
converting XML to canonical XML 210
Cargo-IMP files
XML Converter properties for 375
case sensitivity
Boolean operators and 741
queries and 718
ceiling() function 747
character map
in XSLT 472
1503
1504
1505
configuring
Java components 133
contains() function 735
context node 721
context node set 721
converter URI scheme
building a converter URI 274
displayed in Stylus Studio 272
parts of 269
syntax of 270
using with user-defined .conv files 270
converters
for converting EDI 276
using in an XML pipeline 1053
converting EDI to XML 276
creating custom message types 277
converting operands
to Booleans 742
to numbers 745
to strings 739
count() function 764
creating templates
example 410
how to 439
creating XQuery
using the XQuery Mapper 813
creating XSLT
using the XSLT Mapper 507
cross-language debugging in 1065
cross-language debugging in XML pipelines 1065
CSV files
converting to XML
Custom XML Conversions module 213
current context
number of nodes in 764
current node
1506
definition 721
current() function 766
custom document wizards
about 1176
arguments 1182
command line arguments 1182
configuring 1177
defining arguments 1182
document types for 1180
how to configure 1186
macros for 1178
naming 1179
registering 1177
specifying a command line template for 1180
Custom Document Wizards page in Options dialog box 1178
custom tools
registering in Stylus Studio 122
custom validation engines for XML
about 1170
configuring 1171
macros for 1172
naming 1173
registering 1170
Custom Validation Engines page in Options dialog box 1172
Custom XML Conversion Definition editor
changing fonts in 231
display features for document pane 230
displaying grid lines in 231
displaying pattern matches in 230
displaying the ruler in 230
Go To dialog box 232
custom XML conversions
creating a custom XML conversion definition 222
data type properties 290
field names
display of 229
1507
1508
1509
DataDirect XQuery
collection() function processing 851
execution plans 895
query plans and
updating relational data with 866
date data type properties 296
Date Format data type property 297
datetime data type properties 299
Date-Time Separator data type property 299
debugging
cross-language debugging in XML pipelines 1065
using bookmarks in the XQuery debugger 891
XML pipelines 1065
XSLT processors that support 440
debugging stylesheets
example of 52
parser errors 561
processor errors 561
using breakpoints 552
what output this template generates 557
which template generated output 557
debugging XQuery
bookmarks 891
displaying expressions associated with output 891
displaying process suspension points 890
displaying processing information 889
evaluating XPath expressions 890
local variables and 890
overview 887
using breakpoints 888
watching variables 889
debugging XSLT
bookmarks and 556
breakpoints 552
determining templates associated with output 557
displaying instructions associated with output 556
1510
1511
overview 177
text view of diffed documents 188
tools for documents and folders 176
tree view of diffed documents 187
tuning the diffing algorithm 179
video demonstration 176
viewing documents side-by-side 187
when the diff is calculated 180
while diffing folders 186
XML Diff Viewer
adding documents 193
example 177
tool bar 190
displaying line numbers 12
doc() function
custom URI resolvers for 904
document pane
display features for 230
Document Wizards
generating XQuery from EDI messages 360
document wizards
creating XML Schema from EDI dialects 579
custom document wizards 1176
DTD to XML 140
DTD to XML Schema 569
DTD to XML Schema (Trang) 569
how to use 139
HTML to XML 140
XML Schema to XML 139
XML to XML Schema 574
document() function
using 769
XSLT Mapper and 518
documentation
for XML Schema 643
for XQuery 913
1512
1513
1514
inserting indents 16
line wrap 147
querying a document 17
searching text 148
Sense:X auto-completion 13, 145
setting bookmarks 148
spell checking documents 151
tools for 144
undo 14
wrapping lines 147
editors
selecting lines in 148
Endian data type property 300, 301, 302, 303, 307
examples
bookstore.xml 703
creating dynamic Web pages from XML
three-pane view 401
creating templates 410
stylesheet 379
testing queries 707
tree representation of XML data 704
XML document structure 702
expand all 158
expanded node names
obtaining 762
extension functions
data types 432
declaring 432
finding 434
invoking 434
namespaces 433
XPath data types 433
F
False Output As data type property 293
False Value Match List data type property 293
Fault element in WSDL documents 993
1515
field names
specifying in custom XML conversions
specifying field names in XML output 247
File Explorer
adding files to Projects using
features of 95
filters for 96
opening files with 95
overview 94
setting filters to display files in 96
tool bar 95
file systems
integration with Raining Data 1163
integration with TigerLogic XDMS 1163
files
see also CSV, EDI, and flat files
adding file types to Stylus Studio 99
adding to projects
associating file types with Stylus Studio tools 93
converting non-XML files to XML 213
file types and Stylus Studio module associations 92
making Stylus Studio the default application 99
opening 92
spell checking files in Stylus Studio 151
filters
for XQuery 713
Find
searching XML documents 156
fixed-width files
converting to XML
Custom XML Conversions module 213
flat files
converting to XML
Custom XML Conversions module 213
float data type properties 301
floor() function 746
1516
flow ports
in XSLT Mapper symbols 531
FLWOR blocks
creating 835
Flow port 835
For port 834
illustration 834
in XQuery Mapper 834
Order by port 834
Return port 834
Where port 834
FLWOR expressions
declaring XQuery types using 810
examples 799
for 800
grouping 812
let 803
multiple assignments in 812
order by 807
overview 798
parts of 800
return 808
setting XQuery position variables using 811
where 806
FO processors
in XML pipelines 1017
folders
diffing folder contents 182
Other Documents folder in Stylus Studio projects 102
following axis 730
following-sibling axis 730
fonts
changing 148
colors used in text display 149
in custom XML conversions document pane 231
formatting objects (FO)
1517
1518
HL7
creating XML Schema from HL7 message types 579
HL7 files
XML Converter properties for 375
HMS Separator data type property 310
Home Edition
description 4
HTML
automatic tag completion 428
converting to XML 140
creating with XML Publisher 1092
creating XML documents from 139
creating XSLT 415
I
IATA
creating XML Schema from 577
creating XML Schema from IATA message types 579
message types supported in Stylus Studio 276
IATA files
XML Converter properties for 375
IBM DB2
XQuery support for 852
id() function 757
IDs
finding elements with 757
public IDs for XML Schemas 635
system IDs for XML Schemas 635
temporary 769
IF blocks
in XQuery Mapper 839
images
creating in XML Publisher reports 1125
including in XML Schema documentation 646
import module statement
custom URI resolvers for 904
importing WSDL documents 994
1519
1520
1521
M
Mapper
see XQuery Mapper and XSLT Mapper
mappings
exporting as an image 514, 832
match attribute
comparison with select attribute 385
description 383
matched templates
creating in XSLT Mapper 542
Message element in WSDL documents 984
message types
creating custom EDI message types 277
metrics
XQuery performance 892
XSLT performance 558
Microsoft Office Open XML
using as XQuery data sources 862
using as XSLT data sources 862
Microsoft Office Open XML files
using as XQuery data sources 862
using as XSLT data sources 862
Microsoft SQL Server
XQuery support for 852
modules
creating a library module 882
importing a library module 884
removing a library module 886
multidocument queries
alternatives 770
MySQL
XQuery support for 852
N
name() function 761, 762
named templates
creating in XSLT Mapper 542
1522
axis 732
namespaces
extension functions 433
obtaining information in queries 761
stylesheets 382
namespace-uri() function 762
NCPDP
creating XML Schema from NCPDP message types 579
message types supported in Stylus Studio 276
NCPDP files
XML Converter properties for 375
node sets
comparing 749
node() function 758
nodes
in-place editing in a schema diagram 77
obtaining expanded names 762
obtaining the local name 762
obtaining the namespace URI 762
renaming in the XML Grid tab 165
Normalize White Space data type property 308
normalize-space() function 738
NOT operator 741
not() function 743
Notes data type property 290
number data type properties 304
number() function 745
numbers
converting operands to 745
displaying line numbers in Stylus Studio editors 12
formatting decimal numbers in XML Publisher reports 1141
O
Omit from Output data type property 290
OpenDocument Format
using as XQuery data sources 862
using as XSLT data sources 862
namespace
1523
1524
1525
1526
1527
1528
definition 722
matching template 406
root/element default template
description 438
example 406
round() function 747
S
saving documents
automatic save 211
creating backup copies 211
options for 211
Saxon
processing XQuery with 902
using Saxon to process XSLT 442
Scaling Factor data type property 291, 295, 296, 300, 301, 302, 303, 305, 307, 311
scenarios
definition 39
for Web service calls 960
for XQuery 900
performance metrics reporting 892
for XSLT 39
choosing an XSLT processor 546
how to clone 549
how to create 547
how to run 548
introduction 543
performance metrics reporting 546
setting parameter values 544
specifying source documents 543
XQuery
validating results 909
XSLT
validating results 445
search context
definition 721
queries 721
1529
searching
text 148
using Find to search XML documents 156
using XPath to search for strings 734
SEF
support for in EDI XML Converters 277
select attribute
comparison with match attribute 385
description 384
when there is none 406
selecting lines of code 148
self axis 732
Sense:X
auto-completing tags and fragments 145
Sense:X automatic tag completion
description 13
Sense:X tag completion
XSLT and 428
Service element in WSDL documents 982
short data type properties 307
Signed data type property 295, 302, 303, 307
SOAP requests
modifying 951
parameters for 951
source control
Stylus Studio projects and 109
supported applications 110
SourceSafe
using with Stylus Studio 111
Spell Checker
personal dictionary 154
running 153
settings for 152
using 151
Standard Exchange Format
support for in EDI XML Converters 277
1530
1531
updating
three-pane view 427
XSLT instructions 465
Stylus Studio
associating file types with 93
auto detect feature for Java components 135
benefits 397
building a converter URI using 274
command line for running 128
command line utilities for 128
debugging stylesheets 551
Diff tool 176
Home Edition description 4
managing performance 130
modules that require Java components 133
projects 100
registering custom tools 122
running from the command line 128
using with ClearCase 111, 113
using with SourceSafe 111
using with Visual SourceSafe 111
using with Zeus CVS 116
Web services and 943
XML validation command line utility 129
Stylus Studio Home Edition
description 4
StylusDiff 204
StylusValidator
1532
1533
1534
1535
user-defined functions
creating 844
finding all occurrences of 848
finding the function declaration 849
in XQuery Mapper 838
library modules and 844
refactoring existing code as 845
renaming 849
V
validating
XML Schema 585
validating XML
custom validation engines for 1170
from the command line 129
standard validation engines for 1170
video demonstration 137
validation
using code lists to validate EDI 337
validation engines
in XML pipelines 1017
variables
finding all occurrences in XQuery code 848
finding the variable definition in XQuery code 849
renaming in XQuery code 849
variables in queries 765
video demonstrations
custom XML conversions 276, 1102
Custom XML Conversions module 213
diffing XML sources 176
EDI to XML module 315
Web Service Call Composer 943
XML editing and validation 137
XML Editor Grid tab 162
XML Pipeline Editor 999
XML Publisher 1091
XML Schema Diagram Editor 582
1536
1537
1538
X
X-12
creating XML Schema from 577
X12
creating XML Schema from X12 message types 579
message types supported in Stylus Studio 276
X12 files
XML Converter properties for 375
xln:text() function 740
XML 703
accessing XML documents with 789
auto-completing XML fragments 145
code folding 144
command line utility for validating 129
converting EDI to XML 276
converting XML to canonical XML 210
creating an instance from XML Schema 585
creating from HTML 139
creating XML Schema from an XML document 574
custom validation engines 1170
diffing in Stylus Studio 176
displaying the XML Schema associated with a document 576
generating XML with XQuery 796
pipeline 1000
processing using an XML pipeline 1000
spell checking documents 151
standard validation engines for 1170
using Web service calls as XML 955
viewing a sample based on an XML Schema 585
viewing an XML instance based on XML Schema 585
XML Converters
ATIS file converter properties 375
building a converter URI using Stylus Studio 274
Cargo-IMP file converter properties 375
converting files to and from XML 213
EANCOM file converter properties 375
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
patterns 393
XSL facility
creating new nodes 392
selecting source nodes 387
specifying XSL patterns 393
white space handling 392
XSL processor
applying stylesheets 385
built-in templates 390
specifying result format 391
URI 382
xsl:apply-imports instruction 467
xsl:apply-templates instruction
comparison with xsl:for-each instruction 395
controlling operation order 388
example 388
more than one match 390
no match 390
no select attribute 406
reference 467
selecting nodes 387
specifying patterns 393
xsl:attribute instruction 468
xsl:attribute-set instruction 469
xsl:call-template instruction 471
xsl:character-map instruction 471
xsl:choose
1550
instruction
comparison with xsl:apply-templates instruction 395
reference 479
selecting nodes 387
specifying patterns 393
xsl:for-each-group instruction 481
xsl:function instruction 482
xsl:for-each
xsl:if
1551
1552
1553
1554
1555
1556