Home
Altova XMLSpy 2012 Tutorial
Contents
1. Tutorial ALTOVA lt xmispy eoleg Copyright 6 1998 2012 Altova GmbH All rights reserved Use of this software is governed by and subject to an Altova software license agreement MLSpy MapForce StyuleVision SemanticWorks SchemaAgent UModel Database Spy Diff Dog Authentic Altova sh Missionkit and ALTOVA as well as their logos are trademarks andfor registered trademarks of Altova GmbH Protected by US Patent 7 739 292 XML SSL XHTML and WeSC are trademarks registered in numerous countries oF the world wide Web Consortium marks of the WS are registered and held by ite host institutions MIT INF 1 u JAD and Keio UNICODE and the Unicode Logo are trademarks of Unicode Inc This software ALTOVA contains Jrd party sofkware or material that is protected by copyright and subject to okher berms and conditions as detailed on the Altova website at hho eww alova comi legal A rdparty html Altova XMLSpy 2012 Tutorial All rights reserved No parts of this work may be reproduced in any form or by any means graphic electronic or mechanical including photocopying recording taping or information storage and retrieval systems without the written permission of the publisher Products that are referred to in this document may be either trademarks and or registered trademarks of the respective owners The publisher and the author make no claim to these trademarks While every precaution has been taken in the pre
2. XSLT files can be assigned to specific folders allowing transformations of the XML files in that folder using the assigned XSLT The destination folders of XSL transformation files can be specified for the folder as a whole All the above project settings can be defined using the menu option Project Project Properties In the next section you will create a project using the Project menu Additionally the following advanced project features are available XML files can be placed under source control using the menu option Project Source control Add to source control Please see the Source Control section in the online help for more information Personal network and web folders can be added to projects allowing batch validation Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial Project Management 25 5 2 Building a Project Having come to this point in the tutorial you will have a number of tutorial related files open in the Main Window You can group these files into a tutorial project First you create a new project and then you add the tutorial files into the appropriate sub folders of the project Creating a basic project To create a new project 1 Select the menu option Project New Project A new project folder called New Project Is created in the Project Window The new project contains empty folders for typical categories of XML files in a project screenshot below Hew Project EA
3. complex types for US Address and UK Address by extending the AddressType complex type The content model of US Address is shown below US Address State tpe US State In the XML document in order to specify that the Address element must conform to one of the extended Address types US Address Or UK Address rather than the generic AddressType we must specify the required extended complex type as an attribute of the Address element Do this as follows In the XML document on the Address element enter an xsi type attribute with a value of US Address screenshot below Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 9 E x5 i type H US Address gt o lt tName gt UsS dependency lt Name gt lt Street gt Noble Ave lt Street gt lt li tywsOal aseTi ty lt Zi p gt 04812 zip State gt Texas lt State gt lt fAddres s You can now enter data for the Address element Enter the values shown in the screenshot above Then delete the Person element it will be added in the next section of the tutorial Please note The xsi prefix allows you to use special XML Schema related commands in your XML document instance Notice that the the namespace for the xsi prefix was automatically added to the document element when you assigned a schema to your XML file In the above case you have specified a type for the Address element See the XML Schema specification for more informatio
4. strong d std lt strong Last strong td 4 Select the menu option File Save to save the changes made to the XSL file 5 Click the CompanyLast xml tab to make the XML file active and select XSL KQuery XSL Transformation or press F10 Anew xSL Output html file appears in the XMLSpy GUI in Browser View The background color of the table is yellow 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 22 XMLSpy Tutorial XSLT Transformations Your Company Name US dependency Street Noble Ave City Dallas State Texas fap J4e12 6 Select the menu option File Save and save the document as Company html Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial Project Management 23 5 Project Management This section introduces you to the project management features of XMLSpy After learning about the benefits of organizing your XML files into projects you will organize the files you have just created into a simple project 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 24 XMLSpy Tutorial Project Management 5 1 Benefits of Projects The benefits of organizing your XML files into projects are listed below Files and URLs can be grouped into folders by common extension or any other criteria Batch processing can be applied to specific folders or the project as a whole A DTD or XML Schema can be assigned to specific folders allowing validation of the files in that folder
5. An error message appears in the Messages window saying the file is not valid Mandatory elements are expected after the City element in Address If you check your schema you will see that the US Address complex type which you have set this Address element to be with its xsi type attribute has a content model in which the City element must be followed by a Zi p element and a State element Fixing the invalid document The point at which the document becomes invalid is highlighted in this case the city element Now look at the Elements Entry Helper at top right Notice that the Zi p element is prefixed with an exclamation mark which indicates that the element is mandatory in the current context Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 15 To fix the validation error 1 Place the cursor after the city element and in the Elements Entry Helper double click the Zip element 2 Ensure the cursor is between the start and end tags of the zip element and enter the Zip Code of the State 04812 then confirm with Enter The Elements Entry Helper now shows that the State element is mandatory it is prefixed with an exclamation mark 3 Place the cursor after the Zip element and in the Elements Entry Helper double click the State element Then enter the name of the state Texas Confirm with Enter The Elements Entry Helper now contains only grayed out elements This shows that there are no mor
6. End key if you like and press the space bar This opens a dropdown list this time containing a list of attributes allowed at that point Also in the Attributes Entry Helper the available attributes are listed in red The Manager attribute is grayed out because it has already been used siAddress gt lt Person Manager true lt Llompany Attributes Degree Programmer xsitype Manager Select Degree with the Down arrow key and press Enter This opens another list box from which you can select one of the predefined enumerations BA MA or PhD siAddress Person Manager true Degr e lt lompany gt Select BA with the Down arrow key and confirm with Enter Then move the cursor to the end of the line with the End key and press the space bar Manager and Degree are now grayed out in the Attributes Entry Helper lt S ddress gt Person Manager true Degree BA sLOMpany Programmer a siAddresss lt Person Manager true Degree B 4 Programmer f lt flompany gt f Enter the letter and press Enter Move the cursor to the end of the line with the End key and enter the greater than angular bracket gt XMLSpy automatically inserts all the required child elements of Person Note that the optional Title element is not inserted Each element has start and end tags but no content Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 13 xml ver
7. Schemas enable document designers to specify the allowed structure and content of an XML document and to check whether an XML document is valid Schema editing views in XMLSpy The structure and syntax of an XML Schema document is complex and being an XML document itself an XML Schema must be valid according to the rules of the XML Schema specification In XMLSpy Schema View enables you to easily build valid XML Schemas by using graphical drag and drop techniques The XML Schema document you construct is also editable in Text View and Grid View but is much easier to create and modify in Schema View In the Standard Edition XML Schema documents can be viewed in Text View Schema View and Grid View but can be edited only in Text View Editing in Schema View and Grid View is available in the Enterprise and Professional editions Creating a new XML Schema document To create a new XML Schema file in XMLSpy you must first start XMLSpy and then create a new XML Schema xsd document Create the document as follows 1 Select the menu option File New The Create new document dialog opens Create new document i l Select the type of document you wish to create AML Query Language ABIL Query Language AML Query Language for DBS MIL ate ies BRL eee Schema AL Stylesheet v1 0 ASL Stylesheet v2 0 moll Stylesheet v1 0 ASSLT Stylesheet v2 0 WYinZip File Select a StyleVision Stylesheet Cancel 2 Inthe dialog select the xsd ent
8. of the document in Text View Click the Grid tab to select Grid View In Grid View notice the structure of the document Click on any element to reduce Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 7 selection to that element Your document should look something like this AL version encoding Company mins httg Ain company comnamespace xmins xs http tha es org 2001 AML Schema sischemaLoca http iny company comnamespace AddressLast xsd Address Person blanager 7 Click on the icon next to Address to view the child elements of Address Your document should look like this Company xmins httg Sin company com namespace xmins xs http Shaw org l2001 ML Schema insts esschema http finy company comnamespace AddressLast xsd Address 4 Hame Street City Person Manager 2012 Altova GmbH Altova XMLSpy 2012 Tutorial XMLSpy Tutorial XML Documents 3 2 Specifying the Type of an Element The child elements of Address are those defined for the global complex type AddressType the content model of which is defined in the XML Schema AddressLast xsd Shown in the Grid View screenshot below AddressType tpe xa string We would however like to use a specific US or UK address type rather than the generic address type You will recall that in the AddressLast xsd schema we created global
9. KML Files BA XSL Files XQuery Files EA HTML Files EA DTD Schemas 2 Click the CompanyLast xml tab to make the CompanyLast xml file the active file in the Main Window 3 Select the menu option Project Add active and related files to project Two files are added to the project CompanyLast xml and AddressLast xsd Note that files referenced with Processing instructions Such as XSLT files do not qualify as related files 4 Select the menu option Project Save Project and save the project under the name Tutorial Adding files to the project You can add other files to the project as well Do this as follows 1 Click on any open XML file with the xml file extension other than CompanyLast xml to make that XML file the active file If no other XML file is open open one or create a new XML file 2 Select the menu option Project Add active file to project The XML file is added to the XML Files folder on the basis of its xml file type 3 Inthe same way add an HTML file and XSD file say the Company html and AddressFirst xsd files to the project These files will be added to the HTML Files folder and DID Schemas folder respectively 4 Save the project either by selecting the menu option Project Save Project or by selecting any file or folder in the Project Window and clicking the Save icon in the toolbar or File Save Please note Alternatively you can right click a project folder and select Add A
10. ML DTDSchema Schema design MSL XQuery Authentic View Browser Tools Window Helo DIS ed Ge Om oh a Ce Le CE Project lt M wersi on 1 0 encoding UTF H8 T gt Examples 2 edited with ML spy w4 0 NT ooo mi beta 2 build Jul 6 2001 al el CHttp Afi lt M Spy com by o iin AML Files Wladislav Gavrieloy CAltovay gt orgchart E m OrgChart smil eTaltova_sps Orgchart sps T gt para lt Orgchart m ns Ferson XSL Piles http Aaaa mls py coms Chemas forge cs bold Eg DTD Schemas hart xmlns ipos teritalic xmi nsis i Attp y n Ww orge 00L MLSchema i Attributes 1x Text Grid read only Schema SC 4 Ae Expense Report http a al Cova com IPO ts underline t a mae 2 22 x T ka ML Epy 2009 Examples org chart xml i walid a Entities sMLSpy v2Z009 Registered to Ohas Altova GmbH 1998 2008 Altova GmbH Ln i Col 34 CAF NUM SCRL g The details of the interface are explained as we go along Note that the interface changes dynamically according to the document that is active in the Main Window and according to the view selected Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Schemas 3 2 XML Schemas An XML Schema describes the structure of an XML document An XML document can be validated against an XML Schema to check whether it conforms to the requirements specified in the schema If it does it is said to be valid otherwise it is invalid XML
11. Spy is in the in the Tutorial folder 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 18 XMLSpy Tutorial XSLT Transformations XSLT Transformations Objective To generate an HTML file from the XML file using an XSL stylesheet to transform the XML file You should note that a transformation does not change the XML file into anything else instead a new output file is generated The word transformation is a convention Method The method used to carry out the transformation is as follows e Assign a predefined XSL file Company xs1 to the XML document e Execute the transformation within the XMLSpy interface using one of the two built in Altova XSLT engines See note below Commands used in this section The following XMLSpy commands are used in this section XSL XQuery Assign XSL which assigns an XSL file to the active XML document XSL XQuery Go to XSL opens the XSL file referenced by the active XML document XSL XQuery XSL Transformation F10 or the toolbar icon transforms the active XML document using the XSL stylesheet assigned to the XML file If an XSL file has not been assigned then you will be prompted for one when you select this command Please note XMLSpy has two built in XSLT engines the Altova XSLT 1 0 Engine and Altova XSLT 2 0 Engine The Altova XSLT 1 0 Engine is used to process XSLT 1 0 stylesheets The Altova XSLT 2 0 Engine is used to process XSLT 2 0 stylesheets The correct engine i
12. cation folder typically inc Program Files Altova contains all the XML template files that are used whenever you select the menu option File New These files supply the necessary data namespaces and XML declarations for you to start working with the respective XML document immediately 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 2 XMLSpy Tutorial XMLSpy Interface 1 XMLSpy Interface The XMLSpy interface is structured into three vertical areas The central area provides you with multiple views of your XML document The areas on either side of this central area contain windows that provide information editing help and file management features e The left area consists of the Project and Info windows e The central area called the Main window is where you edit and view all types of XML documents You can switch between different views Text View Schema View Authentic View and Browser View In Standard Edition Grid View and Schema View are read only views they are fully functional editing views in the Enterprise and Professional Editions These views are described in detail in the individual sections about them in the User Manual e The right hand area contains the three Entry Helper windows which enable you to insert or append elements attributes and entities What entries are displayed in the Entry Helper windows depends on the current selection or cursor location in the XML file loj x em File Edit Project
13. checking respectively their check boxes in the Visual Aid pane of the Text View Settings dialog see screenshot above The bookmark feature is useful for setting up markers in your document To insert a bookmark use the command Edit Insert Remove Bookmark Once bookmarks have been inserted you can navigate these bookmarks using commands in the Edit menu The screenshot below shows the current XML file in Text View with all structural editing features enabled For the sake of clarity none of the line numbers indentation guides etc will be shown in Text View in rest of this tutorial Please see the User Manual for more information on Text View Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 11 lt xml version 1 0 encoding UTF 0 t s Company xmins http Mmy comnpany com natt C PROGR A1 tova MLS PY 200P Examples Address xsitypes US Address gt sName US dependency Mame Street Noble Aves Street aCity Dallas Jlity Address gt od mm oh eB Ww hao Editing in Text View In this section you will enter and edit data in Text View in order to become familiar with the features of Text View Do the following 1 Select the menu item View Text view or click on the Text tab You now see the XML document in its text form with syntax coloring lt Yxml version 1 0 encoding LITF a al edited with XML Spy v4 0 7 U http ave mapy com by Alexander Pilz pr
14. ctive File to add the active file to that specific folder Other useful commands Here are some other commonly used project commands e To add anew folder to a project select Project Add Project folder to Project and insert the name of the project folder 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 26 XMLSpy Tutorial Project Management e To delete a folder from a project right click the folder and select Delete from the context menu To delete a file from a project select the file and press the Delete key Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial That s It 27 6 That s It If you have come this far congratulations and thank you We hope that this tutorial has been helpful in introducing you to the basics of XMLSpy If you need more information please use the context sensitive online help system or print out the PDF version of the tutorial which is available as tutorial pdf in your XMLSpy application folder 2012 Altova GmbH Altova XMLSpy 2012 Tutorial Index 29 Index E element type specifying in XML document 8 Entry Helper 2 in Grid View 17 Example files tutorial 1 G Grid View appending elements and attributes 17 using Entry Helpers 17 Info window 2 Main window 2 N New XML document creating 6 O Overview 2 pP Project window 2 Project management in XMLSpy 23 Projects in XMLSpy benefits of 24 how
15. e required child elements of Address Switch to Grid View to view your changes screenshot below XML di Co edited with XML Spy v4 0 U http thew xmlepy corn alex pilz Caltova Company mins http finy company comnamespace xml htp ene es org 2001 AML Schema inst is Fito finy company comnamespace AddressLast xsd Address itype LS Address Hame US dependency i Street Noble Ave Y City Dallas Zip Completing the document and revalidating Let us now complete the document enter data for the Person element before revalidating Do the following 1 Inthe element First enter a first name say Fred Then press Enter 2 Inthe same way enter data for all the child elements of Person that is for Last PhoneExt and Email Note that the value of PhoneExt must be an integer with a maximum value of 99 since this is the range of allowed PhoneExt values you defined in your schema Your XML document should then look something like this in Text View 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 16 XMLSpy Tutorial XML Documents lt xml versi7on 1 0 encoding UTF 8 gt e edited with ML Spy w4 0 1 U Chttp fiw xml spy com by Alexander Filz private gt g lt companty xml ns http ry company Com names pace xmlnsixsi http 4 ai Ws org 2001 sMLSchema 1ns tance 5725 cChemalocati on http nny Company com nanes pace AddressLast sd gt Address
16. editing features of XMLSpy Objective The objectives of this section are to learn how to do the following e Create anew XML document based on the AddressLast xsd schema e Specify the type of an element so as to make an extended content model for that element available to the element during validation e Insert elements and attributes and enter content for them in Text View using intelligent entry helpers e Validate the XML document Commands used in this section In this section of the tutorial you will mostly use the Grid View and Text View and in one section Schema View The following commands are used File New Creates a new type of XML file View Text View Switches to Text View F7 Checks for well formedness F8 Validates the XML document against the associated DTD or Schema e e e Opens the associated DTD or XML Schema file 2012 Altova GmbH Altova XMLSpy 2012 Tutorial XMLSpy Tutorial XML Documents 3 1 Creating a New XML File When you create a new XML file in XMLSpy you are given the option of basing it on a schema DTD or XML Schema or not In this section you will create a new file that is based on the AddressLast xsd schema you created earlier in the tutorial To create the new XML file Select the menu option File New The Create new document dialog opens Create new document q x Select the type of document you wish to create Web Services Description Langua
17. ge er SML Data Reduced Schema whtrnl Extensible Hypertest Markup Language wml DocBook 4 2 Article wml DocBook 4 2 Book smil EJB 2 0 Deployment Descriptor smil Extensible Markup Language wml I45 BAL Document smil J2EE 1 3 Application smil J2EE 1 3 Application Client smil J2EE Connector 1 0 Resource Adapter smil Servlet 2 3 Deployment Descriptor j ee i e l n n nM i i Select a StyleVision Stylesheet Cancel 2 Select the Extensible Markup Language entry or generic XML document entry from the dialog and confirm with OK A prompt appears asking if you want to base the XML document on a DID or Schema IF you intend to create a new 8ML document instance based on a certain schema or DTO XML Spy can automatically add the proper assignment for you in this case please select whether you Intend to base your document on a DTO or Schema Lancel Othenwise please click the cancel button to begin with a new empty document Click the Schema radio button and confirm with OK A further dialog appears asking you to select the schema file your XML document is to be based on Use the Browse or Window buttons to find the schema file The Window button lists all files open in XMLSpy and projects Select AddressLast xsd see Tutorial introduction for location and confirm with OK An XML document containing the main elements defined by the schema opens in the main window Notice the structure
18. ivate lt sCompany xmins hith Siny company comnamespace smia xsi htp Shae ees org 2001 SA MLochema Instance xstechemaLocation hittp imy company comnamespace AddressLast xsqd gt Address xsitype US Address sName US dependency Mame sStreet Noble Ave Street lt City Dallas City gt Text arid schemaf Authentic Browser Untitled xml 2 Place the text cursor after the end tag of the Address element and press Enter to add a new line 3 Enter the less than angular bracket lt at this position A dropdown list of all elements allowed at that point according to the schema is displayed Since only the Person element is allowed at this point it will be the only element displayed in the list Address xsttype US ASddress gt sName US dependency Mame sStreet Noble Ave Street lt City Dallas City gt lt Address ms 4 Select the Person entry The Person element as well as its attribute Manager are inserted with the cursor inside the value field of the Manager attribute Address Person Manager lt lompany gt 5 From the dropdown list for the Manager attribute select true 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 12 XMLSpy Tutorial XML Documents 10 11 Address gt lt Person Manager t company gt Press Enter to insert the value true at the cursor position Move the cursor to the end of the line using the
19. key XML tasks In the process you will learn how to use some of XMLSpy s most powerful features The tutorial is divided into the following parts e Creating an XML Schema You will be introduced to XML Schemas and the various views available in XMLSpy for viewing and editing XML Schemas e Creating an XML document You will learn how to assign a schema for an XML document edit an XML document in Grid View and Text View and validate XML documents using XMLSpy s built in validator e Transforming an XML file using an XSLT stylesheet This involves assigning an XSLT file and carrying out the transformation using XMLSpy s built in XSLT engines e Working with XMLSpy projects which enable you to easily organize your XML documents Installation and configuration This tutorial assumes that you have successfully installed XMLSpy on your computer and received a free evaluation key code or are a registered user The evaluation version of XMLSpy is fully functional but limited to a 30 day period You can request a regular license from Our secure web server or through any one of our resellers Tutorial example files The tutorial files are available in the application folder C Documents and Settings lt username gt My Documents Altova XMLSpy2012 Examples Tutorial The Examples folder contains various XML files for you to experiment with while the Tutorial folder contains all the files used in this tutorial The Template folder in the appli
20. n 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 10 XMLSpy Tutorial XML Documents 3 3 Entering Data in Text View Text View is ideal for editing the actual data and markup of XML files because of its DTD XML Schema related intelligent editing features Structural layout features In addition Text View has a number of viewing and structural editing features that make editing large sections of text easy These features can be switched on and off in the Text View Settings dialog View Text View Settings screenshot below Text iew Settings Margins Tabs Visual aid i Line number margin Tab size 3 M Indentation guides Bookmark margin i Inzert tabs End of line markers i Folding margin Insert spaces Whitespace markers Up One line up D own One line down Left One column left Right Une column right Ctrl Up Scroll one line up Chl D owr Scroll one line down Ctrl Lett One word left Ctrl Right One word right Alt Up ML element move up Alt Down ML element move down Shift Up Select line up The following margins in Text View can be switched on and off e Line number margins e Bookmark margins in which individual lines can be highlighted with a marker e Source folding margins which contain icons to expand and collapse the display of elements Additionally visual aids such as indentation guides end of line markers and whitespace markers can be switched on and off by checking and un
21. n the document To add a new Person element 1 2 J Place the cursor after the already created Person element Press Enter This creates a new line with the cursor positioned at the start of the new line Notice that the Person element is now available in the Elements Entry Helper Double click the Person element in the Elements Entry Helper A new Person element with all mandatory child elements is appended screenshot below Notice that the optional Title child element of Person is not inserted Ferson Manager true Degrees BA FPragranmer Talse gt lt tFirst Fred lt First gt lt Las t Smi Ch lt Las t lt PAONEEXt 2e lt PhNoneext gt f Emad l Smi th awork coms Emai gt lt Person gt Person Manager gt lt First gt lt First gt Las th gy Las Co lt PAONEEX t lt PAOneex th gt Emad 1 gt Ea 1 gt lt Person gt Place the cursor before the closing angular bracket of the opening tag Then in the Append tab of the Attributes Entry Helper double click the Programmer entry This inserts an empty Programmer attribute after the Manager attribute The Programmer attribute is now grayed out in the Attributes Entry Helper Select the menu option File Save As and save the file as CompanyLast xml Remember to rename the original CompanyLast xml file that is delivered with XMLSpy to something else like CompanyLast orig xml Please note The CompanyLast xml file delivered with XML
22. paration of this document the publisher and the author assume no responsibility for errors or omissions or for damages resulting from the use of information contained in this document or from the use of programs and source code that may accompany it In no event shall the publisher and the author be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document Published 2012 2012 Altova GmbH Table of Contents 3 1 32 3 3 3 4 Jo 4 1 4 2 4 3 5 1 S2 Index XMLSpy Interface 2 XML Schemas 3 XML Documents 5 Creaunta New IVE File ose so ctocten ss ance nini E A AEE A 6 Specifying the ype of an Element eessen a a E EASA 8 Entering Data in CXC VIEW coreia ins e reen aa A a EA E E 10 MW alti Me Docume Nt 4 507 acecacctetecetdnteeseundhdacetat E AER A AAN 14 Adding Elements and Attributes code ic ccdetadi cued tecneterd omits ac cotehadenceedassendiouem red 17 XSLT Transformations 18 ASS onne AM ASLI FE seres E AAR 19 Translormint the XAML Fie renia AAR 20 Modiin ME XSLT srren AEA 21 Project Management 23 BEDES 0 Be ed 0 c C a ciri ene nn ne ea ee eee ee 24 J OUUFU GNI aYozerziel eg 0 6 Care nrrnr eee ne nee ete E Pere oer tae nee Pe noe eae E Pe nee oat 25 That s It 27 29 Altova XMLSpy 2012 Tutorial XMLSpy Tutorial 1 XMLSpy Tutorial This tutorial provides an overview of XML and takes you through a number of
23. ree files Schema XML and XSL Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XSLT Transformations 21 4 3 Modifying the XSL File You can change the output by modifying the XSL document For example let s change the background color of the table in the HTML output from lime to yellow Do the following 1 Click the CompanyLast xml tab to make it the active document are in Grid View 2 Select the menu option XSL XQuery Go to XSL sYxml version 1 0 encoading LITF a gt xsl stylesheet versian 1 0 ymin xal http Sawa ses org 99A SL Transtar xine lt 1 hito aay eS org 20004 OXMLSchema instance Simin my http Sy Company comnamespace lt xeltemplate match htrml shead title Your companys titles head lt body gt lt h1l lt cernter our Companysfcenter lt 11 lt xshapply templates select imy Address lt table border 1 bgcolor lime lt thead align center gt td lt strang First strang Ad ctd lt strong Last fstrong td std lt strong Ext lt strang Ad and make sure you The command opens the Company xs1 file referenced in the XML document 3 Find the line lt table border 1 bgcolor lime gt and change the entry bgcolor lLime to bgcolor yellow shl center our Company lt fcenter 1 lt xshapply templates select tmy Address stable border 1 bgcolor yelloyy gt sthead align center gt std strong First
24. ry the document description and the list in the window might vary from that in the screenshot and confirm with OK An empty schema file appears in the Main Window in Schema View screenshot below In Standard Edition you cannot edit XML Schema documents in Schema View so you must switch to Text View to edit the document 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 4 XMLSpy Tutorial XML Schemas 3 The schema you will use for the rest of this tutorial is AddressLast xsd which is located in the c Documents and Settings lt username gt My Documents Altova XMLSpy2012 Examples Tutorial folder Open this file and explore it in Text View and Schema View Note that in Standard Edition you cannot edit this document in Schema View Schema View is a drag and drop editing view in the Enterprise and Professional editions in which you can edit an overview of the schema s global components and then edit each global component in a separate view that component s content model view The XML file you create in the next part of the tutorial will be based on the AddressLast xsd schema so make sure that you do not modify the AddressLast xsd schema that is supplied withy our installation Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 5 3 XML Documents In this section you will learn how to create and work with XML documents in XMLSpy You will also learn how to use the various intelligent
25. s automatically selected by XMLSpy on the basis of the version attribute in the xsl stylesheet or xsl transform element In this tutorial transformation we use XSLT 1 0 stylesheets The Altova XSLT 1 0 Engine will automatically be selected for transformations with these stylesheets when the XSL Transformation command is invoked Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XSLT Transformations 19 4 1 Assigning an XSLT File To assign an XSLT file to the CompanyLast xml file 1 2 3 Click the CompanyLast xml tab in the main window so that CompanyLast xml becomes the active document and switch to Text View Select the menu command XSL XQuery Assign XSL Click the Browse button and select the Company xs1 file from the Tutorial folder In the dialog you can activate the option Make Path Relative to CompanyLast xml if you wish to make the path to the XSL file in the XML document relative 4 Click OK to assign the XSL file to the XML document Switch to Grid View to see the assignment screenshot below edited with AML Spy v4 0 U hip ava Smlepy com by alex pilz Caltova yml stylesheet types texticsl href C Program Files Vattova xh i spy SUTEIEXamples VT utorialCompany xsl Hmins hit iny company conmnamespace minsa http Hae ys org 24001 JAMIL Schema Sirs itty iny Ccompany comnamespace AddressLast xsd Address xsistype U gt S Address An XML stylesheet proces
26. s1 type US Address gt oN anes US dependency Namen Street Noble Ave lt Street gt citys Dal ase ci ty Zi p gt 041l ezip lt State gt Texas e State Address 5 Person Manager true Degree BA Programmer Talse gt lt First gt Fred lt First gt lt Las t Smithe Las t lt PHONeExt gt 22 lt PAOneex tH gt Emad 1 gt Smi th work cams Emai 1 gt lt r Person lt On any 3 Click again to check if the document is valid A message appears in the Messages window stating that the file is valid The XML document is now valid against its schema a Bi eG 8 3 8 x File Documents and Settings My Documents SitovatMLopy20t Examples Tutorialyoompany First xml is walid a 4 4 Select the menu option File Save and give your XML document a suitable name for example CompanyFirst xml Note that the finished tutorial file CompanyFirst xml is in the Tutorial folder so you may need to rename it before you give that name to the file you have created Please note An XML document does not have to be valid in order to save it Saving an invalid document causes a prompt to appear warning you that you are about to save an invalid document You can select Save anyway if you wish to save the document in its current invalid state Altova XMLSpy 2012 Tutorial 2012 Altova GmbH XMLSpy Tutorial XML Documents 17 3 9 Adding Elements and Attributes At this point there is only one Person element i
27. sing instruction is inserted in the XML document that references the XSL file If you activated the Make Path Relative to companyLast xml check box then the path is relative otherwise absolute as in the screenshot above 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 20 XMLSpy Tutorial XSLT Transformations 4 2 Transforming the XML File To transform the XML document using the XSL file you have assigned to it 1 Ensure that the XML file is the active document 2 Select the menu option XSL XQuery XSL Transformation F10 or click the E icon This starts the transformation using the XSL stylesheet referenced in the XML document Since the Company xs1 file is an XSLT 1 0 document the built in Altova XSLT 1 0 Engine is automatically selected for the transformation The output document is displayed in Browser View it has the name XSL Output html If the HTML output file is not generated ensure that in the XSL tab of the Options dialog Tools Options the default file extension of the output file has been set to html The HTML document shows the Company data in one block down the left and the Person data in tabular form below Your Company Name Us dependency street Noble Ave City Dallas State Texas fap 04612 Please note Should you only see a table header and no table data in the output file make sure that you have defined the target namespace for your schema The namespace must be identical in all th
28. sion 1 0 encoding LITF 3 sLompany xmins hith Siny company comnamespace ymis xsi htp Sees es org 200 A MLoEchema instance xetechemaLocation hite siny company comnamespace AddressLast xsq gt eAddress xsitype US Address Name US dependency Mame gt lt Street Noble 4ves Street Lity Dallas lity s Address gt lt Person Manager true Degree BA4 Programmer false gt lt First lt First Last La at lt PhoneEst lt PhoneExt lt Email Email lompany You could now enter the Person data in Text View but let s move to Grid View to see the flexibility of moving between views when editing a document Switching to Grid View To switch to Grid View select the menu item View Grid View or click the Grid tab The newly added child elements of Person are highlighted MIME Company xmins httg Minty company com namespace XMS xsF http thaw ss orgi 001 ML Scheme sieschema http Ainy company comnamespace AddressLast xsd Address xsitype US Address Person Manager Degree Programmer Now let us validate the document and correct any errors that the validation finds 2012 Altova GmbH Altova XMLSpy 2012 Tutorial 14 XMLSpy Tutorial XML Documents 3 4 Validating the Document XMLSpy provides two evaluations of the XML document e A well formedness check e A validation check If either of these checks fails we will have to modify the document appropria
29. tely Checking well formedness An XML document is well formed if starting tags match closing tags elements are nested correctly there are no misplaced or missing characters such as an entity without its semi colon delimiter etc You can do a well formedness check in any editing view Let us select Text View To doa well formedness check select the menu option XML Check well formedness or press the F7 key or click Eil A message appears in the Messages window at the bottom of the Main Window saying the document is well formed Notice that the output of the Messages window has 9 tabs The validation output is always displayed in the active tab Therefore you can check well formedness in Tab1 for one schema file and keep the result by switching to Tab2 before validating the next schema document otherwise Tab1 is overwritten with the validation result 7s mam 9 5 3 x e File C Documents and Settings My Documents Altovaehilspy 2011 Examples TutorialCompanyFirst xml i amp well formed a a Please note This check does not check the structure of the XML file for conformance with the schema Schema conformance is evaluated in the validity check Checking validity An XML document is valid according to a schema if it conforms to the structure and content specified in that schema To check the validity of your XML document first select Text View then select the menu option XML Validate or press the F8 key or click
30. to create 25 T Template folder 1 Text View editing in 10 Tutorial example files 1 goals 1 type extension in XML document 8 V Validating XML documents 14 W Well formedness check for XML document 14 Windows overview 2 X XML document creating new 6 editing in Text View 10 XML document creation tutorial 5 2012 Altova GmbH 30 Index XML documents checking validity of 14 XML Schema tutorial 3 xsi type usage 8 XSL transformation see XSLT 18 XSLT modifying in XMLSpy 21 XSLT transformation assigning XSLT file 19 in XMLSpy 20 tutorial 18 2012 Altova GmbH
Download Pdf Manuals
Related Search
Related Contents
thrill user manual version_1.2 quick start guide now Copyright © All rights reserved.
Failed to retrieve file