52

What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT
Page 2: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Las VegasNovember 27-30, 2001

Page 3: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Las VegasNovember 27-30, 2001

Page 4: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

What the H--- Is XML?

Kean WalmsleyAmericas ManagerDeveloper Consulting Group

Page 5: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

What the H--- Is XML?

• What is XML?• Language Definitions• XML Parsers• Transforming XML• XML Standards• Web Services• XML in Autodesk Products

Page 6: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

What is XML?

• Extensible Markup Language w3.org/xml– Simplification of SGML

• Standard Generalized Markup Language

• A markup language– Adds structure to data

• Can represent any desired structure– A meta-language

• Provides a syntax– Human readable

XML

Page 7: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

• DevNotes structured for on-line Knowledge Base– Separates content from formatting

A Simple Example

Element Attribute

<DevNote ID="1234"><Question>Why am I here?</Question><Answer>Good question.</Answer>

</DevNote>

• The data now becomes much more useful– HTML is only really useful for browsing

– Content mixed with formatting– We can use the structure for many purposes…

XML

Page 8: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Structured Data

• Once structured, data can be– Formatted for display

• e.g. HTML (perhaps several different ways)– Used by an application

• Intelligent search engine indexing just questions• Hand-held device using WML• Hard to anticipate all future uses

• For others to make use of the structure, we must communicate it

XML

Page 9: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Language Definitions

• Element names in XML could be anything– e.g. Question / Answer in our DevNotes– Knowing data is XML is not enough to

understand it

• DTDs and Schemas act as contractsbetween the Producer and the Consumer– Like API definitions

Page 10: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Language Definitions

<!ELEMENT DevNote (Question,Answer) ><!ELEMENT Question #PCDATA >…

Legacy

• Document Type Definitions (DTDs)– Not XML-compliant, inherited from SGML

<xs:schema … ><xs:element name="DevNote" … >

<xs:complexType … >…

Current

• Schemas– XML Schema Definitions, W3C standard

DTD

XSD

Page 11: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML as a Native Format

• XML is verbose– Based on the idea that size doesn’t matter– Used for archival (cheap storage medium)

• Often XML is simply used as a view– Back-end relational/hierarchical database

• More efficient and compact, better indexed

– Data is published or exposed through XML

Page 12: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML Parsers• Tree-based

– e.g. DOM - Document Object Model– Reads entire XML file/stream into a tree-structure

• Needs a lot of memory for a lot of data• Simpler to manage relationships in the data• Good for editing or transforming the content

DOM

<DevNote>

ID="1234" <Question> <Answer>

Page 13: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML Parsers• Event-based

– e.g. SAX - Simple API for XML– Events fired when elements/attributes are read

• Needs much less memory• Caching required to handle relationships

SAX

startElement startElementstartElement characters endElement

<DevNote ID="1234"><Question>Why am I here?</Question><Answer>…

Parsing the XML stream

Events fired

Page 14: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Transforming XML

• Structured data can be transformed

• Multiple renderings of the same data– e.g. DevNotes are published:

• to the Autodesk Developer Network web-site• to the Point A Customization Channel

– We could also publish other formats:• for PDAs, mobile phones• for printed documentation

Page 15: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT
Page 16: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT
Page 17: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Transforming XML

• Extensible Stylesheet Language– Consists of two W3C specifications

• XSL Formatting Objects• XSL Transformations

• XSLT is the most fun!– It can be used to transform XML into

• XML-compliant languages e.g. XHTML, WML• Non-XML formats e.g. RTF, plain text

XSLT

XSL

Page 18: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

<xsl:template match="Question"><h2>Question for DevNote <xsl:value-of select="/DevNote/@ID"/>:

</h2><p><xsl:apply-templates/>

</p></xsl:template>

Transforming XML into XHTML

XSLTstylesheetfragment

HTMLoutput

<h2>Question for DevNote 1234:</h2><p>Why are we here?</p>

XPathlocation

XSLT

Page 19: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

• Where do we transform the data?

– Client side (for XML-compliant browsers)• Add <?xml:stylesheet … ?> to XML file• Using DOM from JavaScript / VBScript

– Server side (works for any browser)• Early rendering batch process, dumps to HTML• ASP / JSP / XSP runtime transformations

Transforming XML into XHTMLXSLT

Page 20: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

A Real Example

• The ADN web-site project– Central database populated from different

data sources– Data extraction uses:

• ADO to query data• MSXML 3.0 DOM to create XML

– Transformed using XSLT stylesheets• Saved as HTML due to browser & search issues

XSLT

Page 21: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

W3C Standards

• The World Wide Web Consortium– Central standards body for all things “web”

• There are many emerging standards in the world of XML…– We have seen XML, XML Schema, DOM, XSL

• Now for some more…

Page 22: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

W3C XML Standards

Access any part of an XML doc from XSLT<xsl:value-of select="/DevNote/@ID"/>

Direct access to XML data fragmentshttp://adn.com/1234.xml#/DevNote/Question

Links between XML documents– Like <A HREF> or <LINK> in HTML

Provides SQL-like access to XML files

XPath

(based onXPath)

XPointer

XLink

XML Query

Page 23: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Web Services

• New breed of web applications– Plumbing for .NET and competing architectures– Component services such as “Passport”– Can encapsulate code on legacy platforms

List

ener

Inte

rnal

Cod

e

ServerXML request

XML response

Page 24: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Web Services

• XML and HTTP used for data transport– Ubiquitous web standards

• Needs other standards “sitting on top” to:– Define how services can be called– Describe the arguments and return types– Allow listing of services in a directory

Page 25: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

W3C Web Service Standards

Simple Object Access Protocol– Remote invocation protocol

Universal Description, Discovery & Integration– Directory service protocol

Web Service Description Language– Expression of service characteristics

WSDL

UDDI

SOAP

Page 26: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML as the API

• Reduces need for proprietary APIs between apps

• Can adopt standard toolsets– Parsers (DOM/SAX) become industry-wide APIs

• No restrictions normally associated with APIs– programming language– operating system– process space / machine location

Page 27: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Producers and Consumers of XML

PurchasingDesign & Engineering-Inventor

Sales

Building Products ManufacturerMarketing Suppliers

Distributor

Architectural Firms

-ADT-AutoCAD

Contractor

Contractor

Building Object Data

Sharing

e-Commerce

Web Content Hosted

e-Commerce

e-Commerce

Page 28: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML Resources

W3C w3.orgXML.com xml.comASP Today asptoday.comXML Software xmlsoftware.comSun Microsystems sun.com/xmlIBM ibm.com/xmlMicrosoft msdn.microsoft.com/xmlHot Dispatch hotdispatch.com

Page 29: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XML in Autodesk Products

• Increasing support and use of XML– More on our initiatives later…

• DesignXML– Introduced in an extension to AutoCAD 2000i– Specification for publishing graphical data at

different levels of detail• 2D Raster for a catalog• 2D Vector for assembly instructions• 3D Facetted for rendered view

Page 30: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

DesignXML in AutoCAD 2002

• Phase 1 was to support full round-trip of model– AcDbXML – the equivalent of DWG/DXF in XML

• AutoCAD 2002 imports/exports AcDbXML– Output via WBLOCK or XmlOut ActiveX method– Input via INSERT or XmlIn

• Uses XML Data Reduced schema standard– www.DesignXML.org/schema/AcDbXML_V_100.xdr

– Now superceded by W3C XML Schema (XSD)

Page 31: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Demo

• Inside AutoCAD 2002– WBLOCK some entities to an XML file– INSERT them back

• “Downstream” from AutoCAD– Run the stylesheet examples

Page 32: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

The DesignGraphicsXML Extension

• DesignXML is being repositioned…– to include both graphical and non-graphical data

• A subset of this is DesignGraphicsXML– What was previously known as DesignXML– Phase 2 implemented in an extension to 2002

• Update to AcDbXML schema• Additional channels…

Page 33: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

The Channels

• Model• Facetted3d• Vector2d• Raster2d• Administrative

AcDbXMLXGLSVGJPG or PNG

All channels can be output from AutoCADAll channels except SVG can be input

A Geometry3D channel is still “on the drawing board”

Page 34: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Admin Channel

<Administrative channelType="Administrative"name="Administrative">

<Title s="Colorwheel sample" /><Subject s="DesignXML Demo" /><Author s=“Kean Walmsley" /><Manager s=“Phil Holcombe" /><Company s="Autodesk" />

…</Administrative>

• File properties information– Can be extended with custom data

Page 35: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Raster – JPG/PNG

• Industry standards for raster images– Uses existing Plot functionality in AutoCAD

Page 36: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

JPG Demo

• Using the Plot mechanism from the toolbar– Show ePlot– Display result in Internet Explorer or Paint

Page 37: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Vector2d - SVG

• W3C standard for 2D vector graphics– www.w3.org/Graphics/SVG

• Web browser plug-in available– www.adobe.com/svg

• Supports animation and effects– AutoCAD does not use these features– XSLT can be used to transform SVG

SVG

Page 38: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

SVG Demos

• XSLT Stylesheets– GIS Adds opacity and labels per layer– AEC Adds hand-drawn effects

SVG

Page 39: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Facetted3D - XGL

• Allows 3d raster image delivery over web– VizStream used in Autodesk Streamline

• AutoCAD supports per-entity material• RealityWave standard

– www.realitywave.com & www.xglspec.org– Zlib compressed version supported (ZGL)

• RealityWave publish a C++ toolkit

XGL

Page 40: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

XGL Demo

• View simple drawing in AutoCAD, exporting it to XGL– Drawing contains viewable and non-viewable

XGL elements

• Load the XGL ouput in viewer

XGL

Page 41: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Model - AcDbXML

• Autodesk’s “Model” channel for AutoCAD– Other Model channels can exist

• Full representation of AutoCAD drawing– Could be used for round-trip editing

• Now defined with a W3C XML Schema– www.DesignXML.org/schema/AcDbXML_V_190.xsd(in Alpha – will change to V_200.xsd on release)

• XML output is different– Conversion XSLT available: AcDbXML_V_100_to_190.xsl

Page 42: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

AcDbXML Demo

• XSLT stylesheets can be used for reporting– Extract data from AcDbXML files– Present HTML output– (Just like previous stylesheets shown)

Page 43: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

DesignGraphicsXML Files

• Each channel is output to a separate file– Can be packaged together by a “header”– The header is the DesignGraphicsXML file

• DesignGraphicsXML files contain channels…– Referenced lighter initial download– Embedded supported but only used for Admin

• Supports Vector/Raster channels– Different views or formats

Page 44: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

DesignGraphicsXML Editor• Creates/edits these “header” files

Only embeds the Admin channel

Page 45: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

DesignGraphicsXML Demo

• Using the DesignGraphicsXML Editor– Output all the channels using the toolbar– Combine them into a header using the editor

Page 46: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

The APIs – COM Automation

• Generic API for input/output/assembly– e.g. batch publishing from VBA or LISP– A single object with five methods

• DxmlIn, DxmlOut, DxmlAssemble, DxmlValidate, DxmlOutSchema

– XML control strings as argumentsdxml.DxmlOut ( _"<Facetted3D fn=""facetted.xgl""/>", … )

Page 47: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

The APIs – ObjectARX/DBX

• For XGL output– Allows additional information to be added– Can assign “path IDs” (like object Ids or handles)

• For custom entity support– As in shipping ObjectARX 2002

• Only desirable for AcDbXML support• Provides custom field names

– Minor updates needed to support new schema

Page 48: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

COM API Demo

• API / SVG / DOM / HTML / Javascript– Mouse Events

• Outputs drawing to SVG• Adds event attributes to SVG• Creates HTML wrapper page

Page 49: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Why use DesignGraphicsXML?

• Leverage industry standard tools– DOM Document Object Model– SAX Simple API for XML– XSLT Extensible Stylesheet Language Transformations

• Case study– Use content (perhaps from >1 channels) at the right level– Publishing building floor-plans to the web using SVG– Use XML DOM to add animation and intelligence

Page 50: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Autodesk Initiatives

i-drop Drag-and-drop from browsersDesignXML Design data schemaRedlineXML Design-related markup schemaLandXML Land development schemaaecXML Architectural schemapXML Catalog-publishing schemayXML …

Page 51: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

yXML ?

• Why? Because…– Structured data is more future-proof– Easy to transform into other formats– Easier to leverage Web Services– Opportunities with Autodesk product-line

• If you can consume XML you will be able to understand everyone

XML

Page 52: What the H--- is XML€¦ · Transforming XML • Extensible Stylesheet Language – Consists of two W3C specifications • XSL Formatting Objects • XSL Transformations • XSLT

Q & A