INTRO TO XMLSPY (IXS)



Similar documents
IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Altova XMLSpy Tutorial

Data Tool Platform SQL Development Tools

Desktop, Web and Mobile Testing Tutorials

How to test and debug an ASP.NET application

For Introduction to Java Programming, 5E By Y. Daniel Liang

Microsoft Office Access 2007 which I refer to as Access throughout this book

Lab 2: MS ACCESS Tables

Create a New Database in Access 2010

Visual Studio.NET Database Projects

Building and Using Web Services With JDeveloper 11g

Toad for Data Analysts, Tips n Tricks

Hypercosm. Studio.

Intellect Platform - Tables and Templates Basic Document Management System - A101

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

USER GUIDE. Unit 2: Synergy. Chapter 2: Using Schoolwires Synergy

Using the Query Analyzer

Microsoft Access 2010 handout

MS OUTLOOK

Microsoft Access 2010 Part 1: Introduction to Access

Embarcadero Rapid SQL Developer 2.0 User Guide

MICROSOFT ACCESS 2003 TUTORIAL

Database Studio is the new tool to administrate SAP MaxDB database instances as of version 7.5.

Microsoft Query, the helper application included with Microsoft Office, allows

DataPA OpenAnalytics End User Training

MS Access Lab 2. Topic: Tables

Mitigation Planning Portal MPP Reporting System

Managing documents, files and folders

Introduction to Microsoft Access 2003

Dreamweaver and Fireworks MX Integration Brian Hogan

BUSINESS OBJECTS DATA INTEGRATOR

Kaldeera Workflow Designer 2010 User's Guide

Editor Manual for SharePoint Version December 2005

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

Adobe Dreamweaver CC 14 Tutorial

Bitrix Site Manager 4.1. User Guide

IBM DB2 XML support. How to Configure the IBM DB2 Support in oxygen

Database Forms and Reports Tutorial

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

WebLOAD IDE User's Guide Version 8.0

Timeless Time and Expense Version 3.0. Copyright MAG Softwrx, Inc.

Tips and Tricks SAGE ACCPAC INTELLIGENCE

Sample- for evaluation purposes only! Advanced Outlook. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

XML Editing with Oxygen. Getting started, tips and tricks

Exclaimer Mail Archiver User Manual

WS_FTP Professional 12

Introduction to MS WINDOWS XP

Richmond SupportDesk Web Reports Module For Richmond SupportDesk v6.72. User Guide

Cal Answers Analysis Training Part III. Advanced OBIEE - Dashboard Reports

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

Introduction to XML Applications

Cal Answers Analysis Training Part I. Creating Analyses in OBIEE

- Training. Getting Started with Outlook Information Technology Services - Training The University of Texas at Austin

How To Use Query Console

EMC Documentum Webtop

WhitePaper. Integration of Altova Tools with IBM DB2 9 purexml demonstrated via the Online Brokerage Application Scenario.

Chapter 19: XML. Working with XML. About XML

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Content Author's Reference and Cookbook

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package Data Federation Administration Tool Guide

Composite.Community.Newsletter - User Guide

Getting Started using the SQuirreL SQL Client

SHAREPOINT 2010 FOUNDATION FOR END USERS

You must have at least Editor access to your own mail database to run archiving.

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

Creating and Using Forms in SharePoint

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

TOPS v3.2.1 Calendar/Scheduler User Guide. By TOPS Software, LLC Clearwater, Florida

Copies of QuickBooks aren t cheap, so the people who do your bookkeeping

MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy

INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB

REAL ESTATE CLIENT MANAGEMENT QUICK START GUIDE

Results CRM 2012 User Manual

Legal Notes. Regarding Trademarks KYOCERA Document Solutions Inc.

Archiving and Managing Your Mailbox

Hands-On Lab. Web Development in Visual Studio Lab version: Last updated: 12/10/2010. Page 1

User Guide for TeamDirection Dashboard

Oracle Data Integrator for Big Data. Alex Kotopoulis Senior Principal Product Manager

Appointment Scheduler

Microsoft Outlook 2010

Search help. More on Office.com: images templates

BID2WIN Workshop. Advanced Report Writing

Business Insight Report Authoring Getting Started Guide

Tutorial 3. Maintaining and Querying a Database

Microsoft Office 2010

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

SourceAnywhere Service Configurator can be launched from Start -> All Programs -> Dynamsoft SourceAnywhere Server.

Before you can use the Duke Ambient environment to start working on your projects or

Crystal Reports Installation Guide

The LSUHSC N.O. Archive

POOSL IDE User Manual

Context-sensitive Help Guide

ORACLE BUSINESS INTELLIGENCE WORKSHOP

WebSphere Business Monitor

CMS Training Manual. A brief overview of your website s content management system (CMS) with screenshots. CMS Manual

NETWORK PRINT MONITOR User Guide

Infor ERP BaanIV / Baan 5.0 / LN 6.1. User's Guide for Worktop 2.4

(These instructions are only meant to get you started. They do not include advanced features.)

Microsoft Office Access 2007 Basics

University of Rochester

Transcription:

INTRO TO XMLSPY (IXS) Student Notebook Intro to XMLSpy Page - 1 Revised: 11/8/2005-3:25:38 PM

Table of Contents Example Files...4 Introduction...5 Course Objectives...6 Three Parts of XMLSpy s Main Window...7 The Editing Views...8 The Technology...9 Creating a New Document...10 Making & Storing Your Own Templates...11 Creating an Instance Document from a Schema...12 Creating an Instance Document from a Schema-(cont d)...13 Context Sensitive Entry Helper Windows...15 Context Sensitive Entry Helper Windows...16 Context Sensitive Entry Helper Windows...17 Well-Formedness and Validation Checking...18 Grid View Editing XML Documents...20 Generating Instance From Schema...22 Differencing Tool...23 Generate a Schema from an Instance Document...24 Creating a Schema: Text & Schema/WSDL View...24 Editing in Schema/WSDL View...27 Generate Documentation from a Schema...30 Generating Program Code from a Schema...31 Generate Java code from Schema...32 Import Database Data (XML Document)...33 XML TABLE Feature Revisited...36 XPath, XSLT Debugging and Transformation...37 XPath...37 XPath Generator...38 XPath Evaluator...38 XSLT...41 XSLT Engines...42 Debugging...44 Debugger Windows...45 Debugger Tools...47 Other XSLT Commands & Toolbar Icons...50 Project Window...51 XMLSpy s Additional Features...60 Intro to XMLSpy Page - 2 Revised: 11/8/2005-3:25:38 PM

Intro to XMLSpy Product Training Target Audience: (a) Software Developers/Data Integration specialists (b) People new to XML technologies willing to do a little pre-work to prepare them for understanding the benefits of using XMLSpy with learning the technologies. What the course is: What the course is not: Pre-work: Intro to XMLSpy will introduce you to the features of XMLSpy that will expedite your development and data integration projects. It s XMLSpy product training. It s not basic XML. To appreciate an introductory amount of what XMLSpy can do, you will need to have at least a basic understanding of XML technologies. For those new to XML Technologies, you will need to have a general understanding of the definitions of the XML Technologies and terms listed below. Consult the resources listed here for your research. Sources: http://www.altova.com/reference_tool.html http://www.altova.com/dev_portal.html http://www.w3schools.com Terms & Technologies XML extensible markup language XSD extensible schema development language XSL extensible stylesheet language XSLT extensible stylesheet transformation language XPath extensible path language Well-formedness Validation This notebook was written to accompany the online, instructor-lead, 2-hour course entitled Intro to XMLSpy. It was not intended as a stand-alone tutorial. Intro to XMLSpy Page - 3 Revised: 11/8/2005-3:25:38 PM

Example Files Example files included in this package: VirtualRecipe.xml VirtualRecipe.xsd VirtualRecipe.xslt VirtualRecipe.html DevgoodChocolatesProducts.mdb Intro to XMLSpy Page - 4 Revised: 11/8/2005-3:25:38 PM

Introduction Secret Agent Niki Devgood The picture you see on your screen is Niki Devgood She s secret agent, Niki Devgood. You ve probably seen her in our ad campaigns. Her characteristics represent our entire Altova product line: She s got technical expertise; adept at data collection and reporting; proficient in numerous languages and dialects; a skilled presenter; always improving and she gets to the information behind the information; and she integrates well! So, XMLSpy isn t spy ware as some may initially think - it s an integrated Development Environment (IDE) for the evolution of XML projects. With its wide range of features, where does one begin learning a product like XMLSpy? Well, it depends on the project you are handed. Today, we are going to start by learning how to navigate the graphical user interface. Then, through a series of exercises, we re going to walk you through how to use the main features of XMLSpy as they relate to specific XML technologies or extensible Markup Language technologies like: XML XSD XSL XSLT XPath The examples we are going to use are built around a case study of the Devgood Chocolate Company. (It s really a field office for the Agency to which Niki reports but don t tell anybody.) The company is in the midst of a rapid growth spurt due to the success its new product line: virtual chocolate. Devgood Chocolate is owned and operated by Grammy Devgood, who, of course, is our very own, Niki Devgood s grandmother. Intro to XMLSpy Page - 5 Revised: 11/8/2005-3:25:38 PM

Course Objectives Using XMLSpy, we will convert the Devgood Chocolate Company s information processing systems into XML. Use the check list below to monitor the progress of the course as we complete topics. You will learn how to: Topics Navigate the three Parts of XMLSpy s Main Window and their purpose The Editing Views New Document Creation Storing New Templates in Program Files Folder Creating an Instance Document from a Schema Context Sensitive Entry Helper Windows Validation Checking Well-formedness Check Upon View Change Grid View Editing XML Documents Generating an Instance Document from a Schema Differencing Tool Generating a Schema from an Instance Document Generating a Schema: Text & Schema/WSDL View Editing in Schema/WSDL View Generating Documentation from a Schema Generating Program Code from a Schema Generating Java Code from Schema Import Database Data in an XML Document XML Table Feature Revisited XPath XPath Generator XPath Evaluator XSLT XSLT Engines Debugging Debugger Windows Debugger Tools Other XSLT Commands & Toolbar Icons Project Window Configuration Tips Intro to XMLSpy Page - 6 Revised: 11/8/2005-3:25:38 PM

Three Parts of XMLSpy s Main Window 1. 1 2 3 Project Window Info Window 2. Main Window or Design Pane Quick Tip CTRL-TAB Drag & Drop The Views: Text Grid Schema/WSDL Authentic Browser You can manage multiple files and URLs by grouping them into folders by common extension or any other order you choose. Displays meta information about the content located where you point your cursor. This is: your work area where the document you are editing appears Views appear once you begin to create a new document or when you open a previously stored document or project file. Depending on the type of document you are editing, determines the views available. You can switch views any time you want by clicking on the appropriate tab. To toggle between open documents Open document names appear on tabs along the bottom of the main window. To change the order in which they appear drag & drop. 3. Entry Helpers These are context sensitive they change based on the type of document that is active in the Main Window. Intro to XMLSpy Page - 7 Revised: 11/8/2005-3:25:38 PM

The Editing Views Edit XML documents in multiple editing formats You can switch among the various views to suit your convenience. Views are XML language sensitive. What does that mean? The type of XML document you have open dictates what views are available. When a document is open, the editing format options appear horizontally along the bottom of the main window like this: Editing Formats Description A text editing view with syntax-coloring. For structured editing. The document is displayed as a structured grid, which can be manipulated graphically. This view also contains an embedded Database/Table view which shows repeating elements in a tabular format For viewing and editing XML Schemas and WSDL documents For editing XML documents and databases based on StyleVision Power Stylesheets (essentially an XSLT stylesheet). An integrated browser view that supports both CSS and XSL stylesheets. NOTES: Intro to XMLSpy Page - 8 Revised: 11/8/2005-3:25:38 PM

The Technology Before we get into it, let s do a quick review of a few terms: REVIEW QUESTIONS 1. What is XML? A. extensible markup language designed to display data and focuses on data transfer B. extensible markup language designed to display data and focuses on how the data looks. C. extensible markup language designed to describe data and focuses on what the data is. D. extensible markup language designed to deliver data and focuses on EDT 2. What is an XML Instance Document? A. An XML document that contains markup and data. B. Must always have an associated DTD or Schema. C. It s the document that describes the data. D. It s a document that displays the data. NOTES: Intro to XMLSpy Page - 9 Revised: 11/8/2005-3:25:38 PM

Creating a New Document From Main Menu: FILE NEW RESPONSE: XMLSpy 2006 comes loaded with the most commonly used industry standard XML document-types. Each document type includes a: root element that serves as the document s starting point. template that references the corresponding DTD or schema a validating parser to extract all relevant information about the content model. constant feedback from the validating parser while you are editing your file. NOTES: Intro to XMLSpy Page - 10 Revised: 11/8/2005-3:25:38 PM

Making & Storing Your Own Templates If you don t see the template you need, you can create your own and file it in the templates folder within your Programs file folder in your installation directory. Storing Your Templates GO TO: Program files folder, for example: To Add the File Name Extension C:\ProgramFiles\Altova\XMLSpy2006\Template From Main Menu: TOOLS OPTIONS FILE TYPES NOTES: Intro to XMLSpy Page - 11 Revised: 11/8/2005-3:25:38 PM

Creating an Instance Document from a Schema Using VirtualRecipe.xsd Let s get back to our project. Back in the old country where the Devgood Chocolate Company was founded, the information processing systems were in a variety of formats. Our mission is to convert the Devgood Chocolate Company s information systems into XML. We re going to start with a virtual chocolate recipe. Niki, being a subject matter expert in intelligence and, of course, XML, created a schema for Grammy so we can use it to build our instance document. But first, a review question: NOTES: 3. What is a Schema Document? A. A rough drawing of a new plan. B. It s another name for a DTD. C. One instance of the data defined by the XML document. D. It defines the content and structure of XML Instance Documents. Intro to XMLSpy Page - 12 Revised: 11/8/2005-3:25:38 PM

Creating an Instance Document from a Schema-(cont d) Two Options from the Main Menu, select OPTION 1: FILE NEW OPTION 2: DTD/SCHEMA GENERATE SAMPLE XML FILE OPTION 1 To Create A New XML Instance Document from a Schema From the Main Menu: FILE NEW RESPONSE: Select: 1. XML Document 2. Click OK Intro to XMLSpy Page - 13 Revised: 11/8/2005-3:25:38 PM

RESPONSE: 1. Document prologue or XML declaration appears, auto generated by XMLSpy: <?xml version="1.0" encoding="utf-8"?> 2. Simultaneously, the option to assign a schema or DTD to your XML instance document also appears. Creating XML Instance Based on an existing Schema RESPONSE: If you are creating a new XML document based on a schema, select the Schema radio button. Select Schema to Associate to your XML document. (VirtualRecipe.xsd) Tools Defined In the Choose a file: box, by clicking on the down arrow, displays a list of documents used recently. The Browse button allows you to search through you computer s stored files. The Window button lets you select a file from other windows open in XMLSpy like your Project files. 3. Now that we ve selected VirtualRecipe.xsd, click OK. Intro to XMLSpy Page - 14 Revised: 11/8/2005-3:25:38 PM

Context Sensitive Entry Helper Windows We now have an XML template that includes the content model from VirtualRecipe.xsd. Using our entry helpers we will: build our instance document in the text view, edit it in the text view, and edit it in the grid view. Elements Helper Window Here s our XML template that includes the content model from VirtualRecipe.xsd: NOTES: Intro to XMLSpy Page - 15 Revised: 11/8/2005-3:25:38 PM

Context Sensitive Entry Helper Windows- (cont d) Once XMLSpy 2006 knows which schema or DTD your document is associated with it uses its integrated validating parser to extract all relevant information about the content model. PLACE CURSOR Place cursor after description element. Auto-filled Helper Windows Elements Helper Window: Notice how the Attributes, Elements and Entities helper windows fill with information. Required elements are automatically highlighted by an exclamation mark. Elements that are allowed within the current parent element, but not at the position of the current selection, are shown in gray. EXAMPLE Meta Information If you place your cursor on a specific line in the XML document, you get meta information about your content in the Information helper window. EXAMPLE With your cursor placed after description, notice: Intro to XMLSpy Page - 16 Revised: 11/8/2005-3:25:38 PM

Context Sensitive Entry Helper Windows- (cont d) Add number attribute to Recipe element Remember in our content model, the element Recipe had an attribute number. How? After: Insert cursor after end quotation mark after: \VirtualRecipe.xsd > Notice how the Attributes entry helper displays: = number. You can either: 1. double click on = number or 2. hit the space bar once and XMLSpy displays a pop up list of elements allowed at that point in the document. 3. Insert the number 1." Another Editing Sample Delete candyname 1. Insert the open bracked (<), a popup list of allowed elements appears. You can then select the appropriate element by clicking on it. All required attributes are entered as well. 2. When you insert the closing bracket (>), the end tag is automatically inserted. 3. The cursor is then positioned between the start and end tag of the element so that you can easily continue to add child elements or content. Intro to XMLSpy Page - 17 Revised: 11/8/2005-3:25:38 PM

Well-Formedness and Validation Checking Now that we have an instance of our schema, is our document well-formed? Is it valid? It s time for a few review questions. NOTES: 4. What is well-formedness? A. Documents that have the same parent elements B. Documents that have the same hierarchical structure. C. Documents that are generated from Authentic and Stylevision D. Documents that conform to the rules and syntax established by the W3C. 5. What is validation? A. Validation confirms that your instance document meets expectations. B. Validation is the process of comparison between a document and its standards. C. A valid document is one that hasn t yet met its expiration date. D. Validation ensures there will be no error codes in your XSLT. 6. What is a valid XML instance document? A. It is one that conforms to the instance B. It only relates to DTDs C. It is one that always contains a namespace D. It is well-formed and conforms to the schema. Intro to XMLSpy Page - 18 Revised: 11/8/2005-3:25:38 PM

Well-Formedness Quick Tips and Validation Checking 1. Should you still manage to create a sequence of elements that violates the content model specified by your schema or DTD or not ensure that your document is well-formed, the built-in incremental validating parser automatically detects the violation and displays its error message directly in the entry helper window along the bottom of your main window. 2. There is an automatic well-formedness check when you change views. If the document isn t well-formed, you won t be able to change views! NOTES: Intro to XMLSpy Page - 19 Revised: 11/8/2005-3:25:38 PM

Grid View Editing XML Documents Adding Content in Grid View Grid View shows the hierarchical structure of XML documents through a set of nested containers that can be easily expanded and collapsed to get a clear picture of the document s structure. Contents and structure can both be easily manipulated. The structure of the document in grid view provides the purest representation of its structure. Benefits of Grid View Grid view allows you to view recurring elements in table form. edit without touching the XML markup view each child-type of the element displayed in a column modify properties for entire columns or selections. (move column titles/change titles, etc. insert row (add data-between other rows) append row (add a new row at the bottom) ascending sort descending sort insert and delete elements and attributes modify names and namespaces do drag and drop reorganizations With VirtualRecipe.xml Click on Grid: Intro to XMLSpy Page - 20 Revised: 11/8/2005-3:25:38 PM

Note: An element is denoted with the icon, an attribute with the = icon. RESPONSE: Three Ways to Add Another Ingredient: First From the parent element ingredients 1. Click and highlight element ingredients 2. From Elements helper window, Click on ADD CHILD (Add c may only be visible) 3. ingredient will appear 4. double click on ingredient Second From ingredient (child element of ingredients) 1. In the grid, click to highlight element ingredient 2. Click Append (or Insert if you prefer), ingredient will appear Third With ingredient highlighted, go to: Menu: Changing Element names & Their Order XML APPEND ELEMENT Change the element name ingredient to contents. Intro to XMLSpy Page - 21 Revised: 11/8/2005-3:25:38 PM

Generating Instance From Schema Creating the Instance Document - Two Options from the Main Menu: Earlier, we promised you another option or another way to create an instance document from a schema. You can also generate a quick instance of your schema from the main menu. OPTION 2 Main Menu RESPONSE DTD/SCHEMA GENERATE SAMPLE XML FILE Click OK and poof! There you have the Instance document from the Schema! Sample XML File Generated from VirtualRecipe.xsd Intro to XMLSpy Page - 22 Revised: 11/8/2005-3:25:38 PM

Differencing Tool Comparing XML files (differencing) From Main Menu: Say for example, Grammy knows that she has two editions of each recipe. One copy has the secret ingredient in it and the other doesn t. But she forgot which was which. Tools Compare Open File With Grammy can compare: Any kind of text-based file Directories Documents Folders Compare VirtualRecipe.xml VirtualRecipe2.xml NOTES: Intro to XMLSpy Page - 23 Revised: 11/8/2005-3:25:38 PM

Generate a Schema from an Instance Document Using VirtualRecipe.xml From Main Menu DTD/SCHEMA GENERATE DTD/SCHEMA In this example, the Schema generated is very similar to VirtualRecipe.xsd. There will be differences though. Creating a Schema: Text & Schema/WSDL View Example shows up to the CandyName element: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs=http://www.w3.org/2001/xmlschema elementformdefault="qualified" attributeformdefault="unqualified"> <xs:element name="recipe"> <xs:complextype> <xs:sequence> <xs:element name="candyname" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:element> </xs:schema> NOTES: Intro to XMLSpy Page - 24 Revised: 11/8/2005-3:25:38 PM

Editing a Schema in Grid View Editing a Schema in Text and Grid View is as easy as editing an XML instance document in text and grid view. The Entry Helpers function the same way. For additional practice, try to recreate segments of VirtualRecipe.xsd in the text view then in grid view. Using the auto generated VirtualRecipe.xsd, try some additional practice with Grid View: Adding Elements in Grid View 1. Highlight the xs:element for candyname. 2. From the Elements Helper box 3. Click on Append, Double click on xs:element RESULT 4. Another xs:element is inserted: 5. Go to Attributes Helper Box, click on Add c (for Child) 6. double click on =name (to insert it) Intro to XMLSpy Page - 25 Revised: 11/8/2005-3:25:38 PM

RESULT 7. click in field next to =name 8. insert element name description 9. With =name description highlighted, for example: 10. Go to the Attributes Entry Helper box 11. Click on the Append tab, 12. Double click on =type 13. indicate type as xs:string RESULT Your schema in grid view now looks like this: What now? Continue in Schema/WSDL View We ve looked at creating or editing a schema in: text view grid view Let s switch to the Schema/WSDL view. We call it Visual XSD: it s the first course in our schema development accelerated series. Intro to XMLSpy Page - 26 Revised: 11/8/2005-3:25:38 PM

Editing in Schema/WSDL View Switch to Visual Schema View Add elements in the visual view. The schema editor in XMLSpy 2006 lets you manage the relationships and definitions in your schema visually. As you develop your schema using the graphical Schema/WSDL view, the corresponding XML code is generated and can be viewed in text view. So, while you design your schema visually, XMLSpy is generating the hand coding for you. Using VirtualRecipe.xsd Here s our VirtualRecipe.xsd in the Schema/WSDL view. Let s walk through how it s done. Go Back to Schema Under Construction Untitled*.xsd Add Child Elements to Recipe Change local elements to global First, add a sequence compositor to Recipe. Then add: ELEMENT NAME COMPOSITOR CHILD ELEMENT NAME DATA TYPE CARDINALITY candyname N/A N/A String description N/A N/A String ingredients Sequence ingredient String 1.. instructions Sequence step String Unbounded Go back change these local elements to global: candyname description ingredients and instructions Intro to XMLSpy Page - 27 Revised: 11/8/2005-3:25:38 PM

Add Attributes Add Facets Enumerated list to productline ELEMENT NAME ATTRIBUTE NAME ATTRIBUTE DATA TYPE Recipe number xs:positiveinteger candyname productline Xs:string 1. Highlight attribute: productline 2. Go to Facets entry helper window 3. Click on Enum tab 4. Click on Append icon 5. Add: Solid, Truffles, Carmels & Virtual Facets- Patterns You can write regular expressions to restrict what is allowed in a particular value space. In XMLSpy, you will use the Patterns feature. We aren t going to use regular expressions in this example but should you need this feature we wanted you to know it s there! 1. With the Patterns tab highlighted, click either Append or Insert. A list of metacharacters and what they represent appear in the drop down list to help you write your regular expression. Result: Intro to XMLSpy Page - 28 Revised: 11/8/2005-3:25:38 PM

Component Navigator in Schema/WSDL Design View Just above that Facets entry helper window is the Component Navigator. Two purposes: 1. To organize global components in a tree view by component type and namespace (see screenshots below). This provides organized overviews of all global components. 2. To enable you to navigate to and display the Content Model View of a global component if the component has a content model. 3. If a component does not have a content model, component is highlighted in the Schemas Overview. Global components that are included or imported from other schemas are also displayed in the Component Navigator. Intro to XMLSpy Page - 29 Revised: 11/8/2005-3:25:38 PM

Generate Documentation from a Schema SCHEMA DESIGN GENERATE DOCUMENTATION Everyone knows how important it is to document your code when you design. XMLSpy makes it easy for you. Let me show you how. Steps 1. From Main Menu, click on SCHEMA DESIGN GENERATE DOCUMENTATION Two Choices of Output Steps (cont d) Benefits: Two choices of output: HTML or Microsoft Word Options of what you would like to include How much detail do you want to see? 2. Choose your preferences 3. Name the output document and save it. Intro to XMLSpy Page - 30 Revised: 11/8/2005-3:25:38 PM

Generating Program Code from a Schema DTD/SCHEMA GENERATE PROGRAM CODE So, we know that XML is not a programming language. However, XML documents are often processed by a computer program. How do we get the computer program to interpret the XML? Well, you could hand code it but we ve got a faster option for you. To create the necessary infrastructure code or in other words to create the required object model you can generate program code from a schema with XMLSpy. Intro to XMLSpy Page - 31 Revised: 11/8/2005-3:25:38 PM

Generate Java code from Schema Step Process Explanation 1. Have schema file open: Code can only be generated from a valid schema file. 2. From main menu DTD/SCHEMA GENERATE PROGRAM CODE 3. Choose Template Dialog box appears 4. Select Java tab* Use this template: c:\program files\altova\xmlspy2006\spl\java.spl 6. Select Target Directory Dialog box ( Browse For Folder ) appears asking you to: Please Select target directory. 7. Open Corresponding Output directory 1. Spy asks you to open the directory you previously created. (For this demo, we will say NO.) 2. The java class files and line of code will be generated. Intro to XMLSpy Page - 32 Revised: 11/8/2005-3:25:38 PM

Import Database Data (XML Document) Devgood Chocolate Product Line The Devgood Chocolate Company s product line is stored in a database. Not to worry though, XMLSpy can import database data from the most commonly used databases. For example, you can import from: Access, MS SQL Server Oracle MySQL Sybase IBM DB2 Convert DevgoodChocolatesProducts.mdb Database Import We re going to import database data into an XML file and generate an XML Schema file to correspond to the database structure. From Main Menu CONVERT IMPORT DATABASE RESPONSE Intro to XMLSpy Page - 33 Revised: 11/8/2005-3:25:38 PM

Importing From Select Database File Name Intro to XMLSpy Page - 34 Revised: 11/8/2005-3:25:38 PM

Click on Import: Voila! Intro to XMLSpy Page - 35 Revised: 11/8/2005-3:25:38 PM

XML TABLE Feature Revisited Table features of imported DevgoodChocolatesProducts With the Devgood Choocolate Company s product list now in XML, let s revisit grid view and how its table feature displays the data. From Main Menu XML TABLE Benefits of Table View: allows you to view recurring elements in table form. Allows you to edit without touching the XML markup You can then modify properties for entire columns or selections. (move column titles/move columns//change titles, etc.) Insert Row (Add data) Append Row Ascending Sort Descending Sort Intro to XMLSpy Page - 36 Revised: 11/8/2005-3:25:38 PM

XPath, XSLT Debugging and Transformation XPath We know that, on its own, an XML Instance Document doesn t do anything. We need to transform the information it holds into something else. To transform it, we need to be able to locate the information or nodes (as they are called) within the XML document. We do that with XPath. REVIEW QUESTION 7. What is XPath? A. A new train line in Boston funded by money left over from the big dig. B. XPath is a language that sends messages via nodes in Schema documents. C. XPath is a language written in expressions designed to locate parts of XML documents. D. XPath is another name for XSLT. Notes: Intro to XMLSpy Page - 37 Revised: 11/8/2005-3:25:38 PM

XPath Generator How do we write XPath expressions? EDIT COPYXPATH Using VirtualRecipe.xml in Grid View Well, learning XPath s syntax and structure is an entirely different class which we offer in the XSLT accelerated series. However, XMLSpy has a tool that will help. 1. Highlight the instructions node 2. From main menu, Edit Copy XPath XMLSpy creates an XPath expression and copies it to the clipboard. (It doesn t create predicates.) /Recipe/instructions This enables you to test your XPath expression Note You may be thinking, why can t you build an XPath expression from the text view? Keep in mind, you aren t evaluating content. You are evaluating the structure. Therefore, the purest structure of the instance document is in the grid view. XPath Evaluator XML EVALUATE XPATH Now what? We can test the XPath expression that we just generated by using the Evaluate XPath feature and see what it returns. Test Expressions: /Recipe/instructions/step And /Recipe/instructions/step[10] Having copied the XPath expression in the grid view open the XPath evaluator: From Main Menu XML EVALUATE XPATH Three sections of The XPath Evaluator opens and you can see it s got three XPath Evaluator distinct sections: input pane options area results pane Intro to XMLSpy Page - 38 Revised: 11/8/2005-3:25:38 PM

XPath Evaluator (cont d) Input Pane The Input Pane is where you paste the XPath expression that you copy. Options Pane Your choices are Meaning of the Choices Allow Complete XPath XML Schema Selector XML Schema Field From Document Root From Selected Element Evaluate when typing Evaluate on button click XPath 1.0 XPath 2.0 Full XPath 1.0 grammar XML Schema Selector grammar XML Schema Field grammar Absolute Path Relative Path Have the evaluator respond as you type real time Results of the evaluator appear when you click on the Evaluate button. XPath Version Results Pane The result is a list of items with their corresponding values. Selecting an item in the list causes that item to be highlighted in the Main Window. Let s test our expression. Test Expression (cont d) Place cursor inside input pane and paste the expression from the clip board into the input pane. /Recipe/instructions/step Take a look at what s returned in the result pane: Intro to XMLSpy Page - 39 Revised: 11/8/2005-3:25:38 PM

RESULT Add Predicate Add a predicate after /step : [11] Look at what s returned after adding the predicate. XPath Generator Doesn t create predicates (segment enclosed in brackets topic covered in Navigating XPath) Intro to XMLSpy Page - 40 Revised: 11/8/2005-3:25:38 PM

XSLT We said just a few minutes ago that by locating nodes, XPath enables other XML technologies to transform data into something else. For example in an XSLT stylesheet. It s review time. REVIEW QUESTION 8. What is XSLT? A. It means the same thing as XSL B. extensible Stylesheet Language Transformation a language for transforming XML C. The same as XHTML D. A formatting objects language Converting VirtualRecipe.xml into HTML with XSLT Stylevision We don t get into the syntax and structure of the XSLT language in this class, which is another class in itself also. However, Niki created a simple stylesheet that we can use to transform our virtual recipe into HTML that will be used on Grammy Devgood s new web site. She likes to feature a recipe every now and then. Niki certainly could have hand coded this stylesheet but to save time, she created it in our product Stylevision and saved the XSLT file that was auto generated. Notes: Intro to XMLSpy Page - 41 Revised: 11/8/2005-3:25:38 PM

XSLT Engines Two Built-in Engines To select an External XSL transformation program: To run a transformation, you need a transformation engine. XMLSpy has two built in engines: 1.0 and 2.0. XMLSpy selects the appropriate engine based on the version attribute in the xsl:stylesheet or xsl:transform element. You use 1.0 with 1.0 XSLT Stylesheets and 2.0 with 2.0 XSLT Stylesheets. For example say you were going to use something like Saxon 8.3: java jar C:\saxon8.3\saxon8.jar o %2 %1 %3 Run Transformation XSL/XQUERY XSL TRANSFORMATION With VirtualRecipe.xml open, run the transformation. This menu choice will not permanently assign the XSLT document to your XML document. If you wanted a permanent assignment, you would either select: XSL/XQUERY ASSIGN XSL XSL/XQUERY ASSIGN SAMPLE XML FILE Intro to XMLSpy Page - 42 Revised: 11/8/2005-3:25:38 PM

RESULT Within seconds you have your HTML output. Something s gone wrong though. Compared to our XML instance document, our list of ingredients is missing. Looks like debugging is in order! Intro to XMLSpy Page - 43 Revised: 11/8/2005-3:25:38 PM

Debugging Using VirtualRecipe.xml and VirtualRecipe.xslt XSLT/XQUERY START DEBUGGER/GO Simultaneous Views Debugger works in text and grid views With VirtualRecipe.xml in the main window, start the debugger. Again, this is not a permanent association. The XSLT/XQuery Debugger interface presents simultaneous view of: Source XML document XSLT/XQuery document Result document Interface Windows Debugging Info While a debugging session is open, information windows in the interface provide information about various aspects of the transformation being executed. Context Variables, XPath Watch, Call Stack Templates Info Messages Intro to XMLSpy Page - 44 Revised: 11/8/2005-3:25:38 PM

Debugger Windows The Context Window displays the current processing context: A sequence of nodes A single node Or an atomic value (string perhaps) Depending on the kind of a context item, its value or attribute/s is/are displayed. Example: 1. if the context item is an element, the element's attributes are displayed. 2. If the context item is an attribute or text node, the node's value is displayed. Note: Clicking an entry in the Context Window, displays that item in the XML document. If the XML document is not currently displayed in the interface, a window for the XML document will be opened. It displays the variables and parameters that are used in the XSLT/XQuery document when they are in scope, and their values. I haven t used any in this XSLT. A little more advanced than my document needed. It enables you to enter XPath expressions that you want to evaluate in one or more contexts. Enter: /Recipe/instructions/step[11] As you step through the XSLT document, the XPath expression is evaluated in the current context and the result is displayed in the Value column. To enter an XPath expression, double-click in the text field under the Name column and enter the XPath expression. Intro to XMLSpy Page - 45 Revised: 11/8/2005-3:25:38 PM

Displays a list of processed XSLT templates and instructions. Clicking an entry in this window, causes the selected XSLT template/instruction to be displayed in the XSLT document window. In other words, by highlighting the template in the Call Stack results list, highlights it in the XSLT document. Displays error messages if you had any Displays the list of templates in your XSLT document. (Not available in XQuery debuggings session.) It provides meta information about the current debugging session. It includes: what debugger is being used, the names of the source and output documents, and the status of the debugger. Intro to XMLSpy Page - 46 Revised: 11/8/2005-3:25:38 PM

Debugger Tools Insert Breakpoint Since we seem to know where our problem is occurring, we can insert break points in our XSLT document to interrupt the processing close to that point so that we can evaluate what the problem is. Benefit This speeds up debugging sessions since you do not have to step through each statement in the XSLT or XQuery document manually. The debugger only stops at those designated points. Describe Debugger Tools Insert/Remove Breakpoint (F9) Insert the Breakpoint Note: Inserts or removes a breakpoint at the current cursor position. Inline breakpoints can be defined for nodes in both the XSLT/XQuery and XML documents, and determine where the processing should pause. A dashed red line appears above the node when you set a breakpoint. Breakpoints cannot be defined on closing nodes, and breakpoints on attributes in XSLT documents will be ignored. This command is also available by rightclicking at the breakpoint location. In VirtualRecipe.xslt on line 41, insert the breakpoint. The example bug is a misspelling of ingredients (ingrediants). Intro to XMLSpy Page - 47 Revised: 11/8/2005-3:25:38 PM

XSLT Breakpoints Dialog This command pops up the XSLT/XQuery Breakpoints dialog, which displays a list of all currently defined breakpoints (including disabled breakpoints) in all files in the current debugging session. Check Boxes Enables ( ) breakpoint Disables ( ) breakpoint Removes the highlighted breakpoint Removes ALL breakpoints Highlighted, it takes you directly to that breakpoint in the file. Intro to XMLSpy Page - 48 Revised: 11/8/2005-3:25:38 PM

Options for Proceeding Through your XSLT Document XMLSpy offers you several ways in which you can proceed or progress through your debugging session. You can: Start Debugger/Go Step Into Step Over Step Out Start Debugger/Go Starts or continues processing the XSLT/XQuery document till the end. (unless you put in breakpoints) Step Into The Step Into command proceeds in single steps through all nodes and XPath expressions. Step Over Steps over the current node to the next node at the same level, or to the next node at the next higher level from that of the current node. Step Out Steps out of the current node to the next sibling of the parent node, or to the next node at the next higher level from that of the parent node. Each one of these options can also be used to restart the debugger after it has been stopped. Finish Running Debugging Fix typo and Step Over to continue. Session and Correct Bug Stop debugger pauses the debugger. You can edit any of your documents while the degugger is paused. All editing features that are available in your XMLSpy 2006 environment are also available while editing a file during a debugging session. End debugging session concludes the debugging session. When you stop a debugging session, it closes the XSLT/XQuery Debugger interface and returns you to your previous XMLSpy 2006 environment. Intro to XMLSpy Page - 49 Revised: 11/8/2005-3:25:38 PM

Other XSLT Commands & Toolbar Icons Show current execution node Displays/selects the current execution node in the XSLT/XQuery document and the corresponding context node in the XML document. This is useful when you have clicked in other tabs which show or mark specific code in the XSLT stylesheet or XML file, and you want to return to where you were before you did this. Restart Debugger Clears the output window and restarts the debugging session with the currently selected files. The View Icons Now, having completed the debugging session, show the Output document by clicking on the vew icons in reverse order: View XML, XSL, Output The current view View XSLT and Output XSLT and Output View the Active Document Only Here s our end product, the HTML Output - VirtualRecipe.html Grammy Devgood s html recipe. Intro to XMLSpy Page - 50 Revised: 11/8/2005-3:25:38 PM

Project Window Project Now that we have created all of these files, let me show you how you can store them in XMLSpy. Intro to XMLSpy Page - 51 Revised: 11/8/2005-3:25:38 PM

Function of the Project Window You can: organize files and groups of files in a tree-like structure group folders by common extension or any way you choose add file types you don t see here that you commonly use, Execute batch operations across files Project folders are: semantic folders that represent a logical grouping of files. They do not need to correspond to any hierarchical organization of files on your hard disk can correspond to physical directories on your file system Managed similarly to a short cut. PROJECT NEW PROJECT Open a new project and begin saving the files you created. opens a new project. The new project will be named New Project. When you go to Save Project, you will be prompted to name the project. When to create your Project You can create and save in your project file whenever you choose. Normally, you would add files to your project as your project progresses. In this situation, we use a previously created project file and are drawing from it for this course. Intro to XMLSpy Page - 52 Revised: 11/8/2005-3:25:38 PM

Reload Project If you are working in a multi-user environment, it can sometimes become necessary to reload the project from disk, because other users might have made changes or updates to files within it. Close Project Closes the project. Save Project Saves the project. Add Files to Project Enables you to add files to the current open project and distributes them among the respective folders based on the file type extensions defined in the project properties dialog box. You can save a single file or a group of files (Ctrl+ click). Intro to XMLSpy Page - 53 Revised: 11/8/2005-3:25:38 PM

Add URL to Project Adds a URL to the current project. URLs in a project cause the target object of the URL to be included in the project. Whenever a batch operation is performed on a URL or on a folder that contains a URL object, XMLSpy retrieves the document from the URL and performs the requested operation. Add Active File to Project Add Active and Related Files to Project Add the open file to the open project. Adds any related files to the project. For example, say we are adding the VirtualRecipe.xml to the project, we know that it is related to the VirtualRecipe.xsd. Therefore, XMLSpy will also add the related schema. Intro to XMLSpy Page - 54 Revised: 11/8/2005-3:25:38 PM

Add Project Folder to Project Note: This command retrieves the same properties box as Project Properties. Use this command to add a new folder to the current project or a sub-folder to a project folder. For example, Niki added database files to this project and created a folder for Database Files. She did this using the Add Project Folder to Project command and added Database Files with the.mdb File Extension You can also access this command from the context-menu when you right-click on a folder in the project window. Intro to XMLSpy Page - 55 Revised: 11/8/2005-3:25:38 PM

Add External folder to Project Allows you to add any other folder from files or folders on your computer to your project. This is how I added the link to the Java generated files you see in my project. Filter You can also filter the files included by going to the Properties box and entering the file extensions of the file types you want to see. Intro to XMLSpy Page - 56 Revised: 11/8/2005-3:25:38 PM

Add External Web Folder to Project You can also add web folders to your project. These can be filtered as well. We haven t done that here in our example. Intro to XMLSpy Page - 57 Revised: 11/8/2005-3:25:38 PM

Batch Manipulation/ Project Properties You can assign: XSL transformation to project folders DTDs/Schemas to project folders Intro to XMLSpy Page - 58 Revised: 11/8/2005-3:25:38 PM

Last note on project. PROJECT OPEN PROJECT VERSUS FILE OPEN Be sure you use the Project Open menu selection to open your project. If you use File Open, you will be opening the actual XML file of your project! Intro to XMLSpy Page - 59 Revised: 11/8/2005-3:25:38 PM

XMLSpy s Additional Features Graphical editing view of XML documents in Authentic View XMLSpy also provides a graphical editing view of XML documents in Authentic View which enabling users to enter data into an XML document as they would into a wordprocessor-type application. Authentic View is particularly useful in situations where: people not familiar to XML are called upon to enter data into an XML document, or where several users input data into, or view, a single document located on a server or shared resource. WSDL and SOAP The Schema/WSDL View enables you to create and edit WSDL documents in an easy-to-use graphical interface. You can also create and edit SOAP requests within the IDE and debug SOAP requests. Visual Studio.NET integration Eclipse Development Platform XMLSpy can be integrated in your Visual Studio.NET environment. You can access XMLSpy editing views and XML development tools from within the Visual Studio.NET. To do this, you will need to install either the Enterprise or Professional Edition of XMLSpy, Microsoft Visual Studio.NET 2002 or 2003 and XMLSpy s integration module. Altova supports Eclipse integration in its Home Edition as well as with the Enterprise and Professional Editions. XQuery XMLSpy 2006 includes schema-aware support for XQuery 1.0, including creating, editing, debugging, and executing XQuery files. Intro to XMLSpy Page - 60 Revised: 11/8/2005-3:25:38 PM