1 / 39

Mastering XML: Understanding its Power and Uses in Data Management

This comprehensive guide explores the history and significance of XML, its defining features, and practical applications. Learn how XML enables structured data descriptions, fosters data exchange, and empowers data storage and retrieval. Discover how XML complements HTML and drives innovation in programming. Dive into the world of Mastering ACT V2 2005 and the role of XML in its advanced functions.

jaquez
Download Presentation

Mastering XML: Understanding its Power and Uses in Data Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML – Why Do You Care & What Can You Do With It Patricia (Pat) Egen Patricia Egen Consulting, LLC 423-875-2652 Mastering ACT V2 2005

  2. A Brief History Lesson • It all began with HTML • Actually, it all began with SGML, but that’s another story • But the people wanted more…. • HMTL is a way to “display” data and information • in other words, it focuses on how data “looks” • HTML tags are predefined in the standard – and you can’t add your own • People needed a way to describe their data and they needed a way to come up with their own tags Mastering ACT V2 2005

  3. Er, What’s a Tag? • Ever looked at pure HTML code • All the funny text inside of these brackets (<>) are tags • Here’s some examples of tags: • <br> - this stands for begin break • </br> - this stands for end break • <b> - this turns on Bold • <table> - this is the start of a table • <ul> - Anyone know what this is? Mastering ACT V2 2005

  4. XML – A Definition • The politically correct version: • Extensible Markup Language, abbreviated XML, describes a class of data objects called XML documents and partially describes the behavior of computer programs which process them. XML is an application profile or restricted form of SGML, the Standard Generalized Markup Language [ISO 8879]. By construction, XML documents are conforming SGML documents. • …” Its goal is to enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML has been designed for ease of implementation and for interoperability with both SGML and HTML.” • XML documents are made up of storage units called entities, which contain either parsed or unparsed data. Parsed data is made up of characters, some of which form character data, and some of which form markup. Markup encodes a description of the document's storage layout and logical structure. XML provides a mechanism to impose constraints on the storage layout and logical structure. • Source: Extensible Markup Language (XML) 1.0 (Third Edition) - W3C Recommendation 04 February 2004 Mastering ACT V2 2005

  5. The “Ah, that’s what it means” version • XML is a way to define or describe data • in other words, it focuses on what data “is” not what it looks like • And you can “roll your own” xml tags • It’s a way to define data in a way that any other program (that speaks XML) can understand it. • Think of it as an interpreter. • XML is a language for documents containing structured information. Mastering ACT V2 2005

  6. XML in a Nutshell • XML stands for EXtensible Markup Language • XML is a markup language like HTML. • XML was designed as a way to describe data. • XML tags are not predefined in XML - you must define your own tags. • XML is self describing - all the rules are contained in the text. • XML uses a DTD (Document Type Definition) or Schema to formally describe the data • It’s a universally accepted standard way of structuring data – basically it’s the syntax Mastering ACT V2 2005

  7. A little more clarification • HTML • provides a standard, fixed way to present DATA • responsible for the explosive growth of the Web • is designed to present DATA for human consumption • XML • provides a standard, flexible way to describe the meaning of DATA • provides the structure needed to be machine processed • provides a data exchange between applications or machines Mastering ACT V2 2005

  8. How can you use XML? • XML can keep data separated from your HTML pages • Web pages change, but data may not • XML can be used to store data inside HTML documents • XML can be used as a format to exchange information • This is what is happening within ACT • XML can be used to store data in files or in databases • Ditto for ACT • XML can be used to define data for reports or templates Mastering ACT V2 2005

  9. XML and .NET • Microsoft saw the power of XML and has put a lot of code that uses and processes XML into the .NET framework. • Easy for an application developer to use XML for its parameter-type data storage • By parameter, we mean finding data based on a specific syntax – contact, name, address, activity, start date, etc. • A developer just calls the Microsoft .NET code. • If you want the same function but don’t want to use XML, you would need to create the entire read/write/modify code to read your own data store • If you need the functions provided by the XML .NET library code but choose not to use XML you are reinventing the wheel just to not use XML • From the standpoint of the application developer, if you have bought in to .NET, you are better off using as much of the Microsoft code as you can. Mastering ACT V2 2005

  10. XML and ACT • After working with .NET now for a while, it becomes apparent why ACT 2005/2006 heavily uses XML for its "parameter" type data storage • When you look around in Windows Explorer you will find a ton of XML formatted objects that ACT uses • Report formats, calendar print extracts, definitions of the ACT interface to Microsoft IIS, Sync configurations, etc. Mastering ACT V2 2005

  11. Now, Let’s look at Data • Here’s an example of some data • Now you need a way to structure it so other programs can identify the data and knows what it really means Mastering ACT V2 2005

  12. Data the XML Way • Data to XML is “wrapped” in tags • For example, our data would be constructed like the following: <Contact> <fname>John</fname> <lname>Doe</lname> <address1>123 Main Street</address1> <city>BigCity</city> <state>TN</state> <zip>37445</zip> </Contact> Mastering ACT V2 2005

  13. Some XML Terminology • Let’s look at one line of our data • Here’s what the items are called in XML terminology Mastering ACT V2 2005

  14. Drilling a Little Deeper • Here’s a date: <date>11-12-2005</date> • Simple enough – or is it? • Are we in Europe? Is the 12th of November or the 11th of December? • XML is good about describing data but we need a little more information about this date – we need a definition or METADATA • In XML speak, we need an ATTRIBUTE • Here’s the same thing, only different • <date format=“mm-dd-yy”>11-12-2005</date> Mastering ACT V2 2005

  15. More on Attributes • Attributes give additional information about a TAG. • An HTML example would be the font tag • <FONT color="#FF0000"> • This example shows the HEX representation of the RR GG BB color RED – this then tells the Browser whatcolor to use. • Just like in HTML, XML attributes allow you to specify additional data about a TAG • Here’s another example:<PC OS="NT" >Desktop standard</PC>The important item to note here is thatthe quotes are REQUIRED. Mastering ACT V2 2005

  16. Introducing Schemas • Ok, so we have tags, attributes and data all combined in Elements. • Sounds simple enough • However, a bunch of elements all thrown together may not turn out exactly what you want as an end results • You need a set of rules, that you define, the control the way elements can be used inside an XML document • A SCHEMA is this set of rules • Note – before schemas these rules were called DTDs – Document Type Definitions • Schema file types are XSD Mastering ACT V2 2005

  17. Makeup of a Schema • A Schema will contain the following: • elements that can appear in a document • attributes that can appear in a document • which elements are child elements • the order of child elements • the number of child elements • whether an element is empty or can include text • data types for elements and attributes • default and fixed values for elements and attributes • Think of a schema as an “outline” of how the data should be interpreted Mastering ACT V2 2005

  18. Simple Schema to Define a Classroom Table <xs:element name="ClassRoom"> <xs:complexType> <xs:sequence> <xs:element name="ID" type="xs:string" /> <xs:element name="Floor" type="xs:unsignedByte" /> <xs:element name="RoomNumber" type="xs:string" /> <xs:element name="timestamp" type="xs:base64Binary" /> </xs:sequence> </xs:complexType> </xs:element> Mastering ACT V2 2005

  19. Another “Interesting” Schema Example <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.frontrange.com/goldmine/xmlexport" xmlns="http://www.frontrange.com/goldmine/xmlexport" version="1.1"> <xs:element name="gmdata"> <xs:complexType> <xs:sequence> <xs:element ref="header" minOccurs="1" maxOccurs="1"/> <xs:element ref="general_data" minOccurs="0" maxOccurs="1"/> <xs:element ref="accounts" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="header"> <xs:complexType> <xs:sequence> <xs:element ref="goldmine_version" minOccurs="1" maxOccurs="1"/> <xs:element ref="gmdbdef" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType> </xs:element> Mastering ACT V2 2005

  20. ACT6.map.xml <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE DiscoToMercuryMappingInformation[ <!ELEMENT FieldMapping ANY> <!ELEMENT MappingSection ANY> <!ELEMENT MapEntry ANY> <!ATTLIST MapEntry discoID ID #REQUIRED> <!ELEMENT MappedTo ANY> <!ATTLIST MappedTo mercID ID #REQUIRED> <!ELEMENT MercuryList ANY> <!ELEMENT MercuryField ANY> <!ELEMENT MercuryGroup ANY> <!ATTLIST MercuryGroup name ID #REQUIRED>]> <DiscoToMercuryMappingInformation> <FieldMapping> <MapEntry discoID="Contact.25"> <MappedTo mercID="TBL_CONTACT.COMPANYNAME" /> </MapEntry> <MapEntry discoID="Contact.26"> <MappedTo mercID="TBL_CONTACT.FULLNAME" /> </MapEntry> …… FieldMapping is defined here • This is an example of a Schema that is used within ACT. • This is the act6.map.xml file found in the Conversion folder under Documents and Settings/Application Data And then called here Mastering ACT V2 2005

  21. XML Editors and Parsers • XML Spy • www.xmlspy.com • XMLwriter • www.xmlwriter.net • Microsoft XML Notepad • www.softlookup.com/display.asp?ID=23257 • Internet Explorer Mastering ACT V2 2005

  22. Microsoft XML Notepad Mastering ACT V2 2005

  23. The job of an XML parsing tool is to validate that the XML is structured correctly (called Well Formed), is valid, i.e. doesn’t contain errors, and follows the rules of schemas or DTD’s The job of XML Validation Mastering ACT V2 2005

  24. Internet Explorer makes a dandy XML Parser. Just click on an XML file and IE will tell you if there is a problem with the file Internet Explorer as an XML Parser Mastering ACT V2 2005

  25. A Bad XML File Example • Here’s an example of a bad, or broken XML file. • IE will attempt to tell you what it found wrong with the XML code. Mastering ACT V2 2005

  26. ACT XML files • PAD files • Reports • Label and envelope templates • Print templates • Configuration Files • Sync • Internet Links • Preferences Mastering ACT V2 2005

  27. ACT Tables • You need to know the valid field names in your Logical Tables in ACT as well as the table names • The main tables are: • Contact, Secondary Contacts, Group, Company, Notes, History, Activities, Opportunities, Products • These are the tables you care about for coding XML stuff • Use ACT7Diag to see the internal field and table names. • Where you see a Table name, place TBL_ in front of the table name when calling the field in XML. • Example: TBL_Contact • Physical Tables • There are anywhere from 100 to 150 • These you need the infamous SA Password Mastering ACT V2 2005

  28. Here’s a sample from ACT7DIAG PEC_Master Database Fields Report from ACT7Diag Oct 13 2005 9:45PM Database Product Version: 8.00.818 Database Server Name: PAT01\ACT7 Schema Version: 07.04.0075.0000 Database File Location: C:\Documents and Settings\Pat\My Documents\PEC_Master.ADF CONTACT Entity Field Statistics (by table): ------------------------------------------------------------- Table: Contact Record Count: 1086 Field Count: 122 (89 Physical, 33 Virtual, 0 Calculated) (in approx. bytes) Supported Pagesize: 7584, Current Pagesize: 7379, Available Pagesize: 205 ACT! Field: 2nd Contact ACT! Fieldtype: Character(50) Custom:1 Ordinal:56 Displayed:1 Define Fields:1 ACT! Field: 2nd Last Reach ACT! Fieldtype: Date Custom:1 Ordinal:71 Displayed:1 Define Fields:1 ACT! Field: 2nd Phone ACT! Fieldtype: Character(32) Custom:1 Ordinal:58 Displayed:1 Define Fields:1 ACT! Field: 2nd Phone Ext- ACT! Fieldtype: Character(8) Custom:1 Ordinal:64 Displayed:1 Define Fields:1 ACT! Field: 2nd Title ACT! Fieldtype: Character(50) Custom:1 Ordinal:57 Displayed:1 Define Fields:1 ACT! Field: 3rd Contact ACT! Fieldtype: Character(50) Custom:1 Ordinal:59 Displayed:1 Define Fields:1 ACT! Field: 3rd Last Reach ACT! Fieldtype: Date Custom:1 Ordinal:72 Displayed:1 Define Fields:1 ACT! Field: 3rd Phone ACT! Fieldtype: Character(32) Custom:1 Ordinal:61 Displayed:1 Define Fields:1 ACT! Field: 3rd Phone Ext- ACT! Fieldtype: Character(8) Custom:1 Ordinal:65 Displayed:1 Define Fields:1 In XML this would be TBL_Contact In XML this would be a field name Mastering ACT V2 2005

  29. Dissecting an ACT XML File • A standard PAD file <?xml version="1.0" standalone="no"?> <!DOCTYPE ACT2005DatabasePADFile> <!--This file represents a Pointer to an Act Database or [PAD]--> <ACT2005Database name="PEC_Master" host="." location="C:\Documents and Settings\Pat.PEC\My Documents\ACT\ACT for Win 7\Databases" type="Sql" /> This points at a DTD located somewhere within the ACT code This is an element with a series of tags and attributes Mastering ACT V2 2005

  30. Adding Internet Links to ACT Mastering ACT V2 2005

  31. Adding a Link to ACT Internet Links • Say you want to add a link to the ACT URL to do Yahoo Maps Local Info lookups • To start with, find the actual URL Yahoo link: • http://local.yahoo.com/?csz=Phoenix%2C+AZ • Here's the XML code in the Internet links for doing that search: Mastering ACT V2 2005

  32. Kicking Internet Links up a notch • So...., taking our example another step let’s add a link for a Yahoo Map • Here's a real URL link for Yahoo Search for an address called 827 Broad Street in the 37402 zip code: • http://maps.yahoo.com/maps_result?addr=827 Broad Street &csz=37402&country=us&new=1&name=&qty= • And here's what it looks in XML on the internetlinks.xml file. • By the way, this works - I added it to mine. Mastering ACT V2 2005

  33. Adding Yahoo Maps – Step by Step Mastering ACT V2 2005

  34. Yahoo Maps – After Adding to Internet Links Yahoo Maps Mastering ACT V2 2005

  35. The Yahoo Results Mastering ACT V2 2005

  36. Now, Let’s try Report Modifications • All Reports in ACT are in XML • Make sure you download the Documentation for the actual Report Writer from ComponentOne • http://helpcentral.componentone.com/Documentation.aspx • Open the Reports folder in Windows • Find a favorite report • Open it with Notepad or one of the XML editors • Save a copy – play with the reporting to see what kind of different results you can achieve Mastering ACT V2 2005

  37. Homework Assignments • So, if you think this is something you’d like to learn more about, try Google to lookup information on the following extra credit items • XSL – XML Style Sheets • NameSpaces • IDs • CDATA Blocks • Child Elements • Entities • DTD’s • XPath Mastering ACT V2 2005

  38. Where to find more info • http://www.w3.org/TR/2004/REC-xml-20040204/ • http://msdn.microsoft.com/xml/ • http://www.thescarms.com/XML/SchemaTutorial.asp • http://developer.yahoo.net/search/local/V1/localSearch.html • Interesting links • http://www.ibiblio.org/xml/examples/shakespeare/ Mastering ACT V2 2005

  39. Questions? Mastering ACT V2 2005

More Related