what the h--- is xml€¦ · transforming xml • extensible stylesheet language – consists of...
Post on 29-Sep-2020
11 Views
Preview:
TRANSCRIPT
Las VegasNovember 27-30, 2001
Las VegasNovember 27-30, 2001
What the H--- Is XML?
Kean WalmsleyAmericas ManagerDeveloper Consulting Group
What the H--- Is XML?
• What is XML?• Language Definitions• XML Parsers• Transforming XML• XML Standards• Web Services• XML in Autodesk Products
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
• 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
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
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
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
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
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>
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
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
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
<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
• 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
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
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…
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
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
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
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
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
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
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
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
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)
Demo
• Inside AutoCAD 2002– WBLOCK some entities to an XML file– INSERT them back
• “Downstream” from AutoCAD– Run the stylesheet examples
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…
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”
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
Raster – JPG/PNG
• Industry standards for raster images– Uses existing Plot functionality in AutoCAD
JPG Demo
• Using the Plot mechanism from the toolbar– Show ePlot– Display result in Internet Explorer or Paint
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
SVG Demos
• XSLT Stylesheets– GIS Adds opacity and labels per layer– AEC Adds hand-drawn effects
SVG
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
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
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
AcDbXML Demo
• XSLT stylesheets can be used for reporting– Extract data from AcDbXML files– Present HTML output– (Just like previous stylesheets shown)
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
DesignGraphicsXML Editor• Creates/edits these “header” files
Only embeds the Admin channel
DesignGraphicsXML Demo
• Using the DesignGraphicsXML Editor– Output all the channels using the toolbar– Combine them into a header using the editor
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""/>", … )
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
COM API Demo
• API / SVG / DOM / HTML / Javascript– Mouse Events
• Outputs drawing to SVG• Adds event attributes to SVG• Creates HTML wrapper page
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
Autodesk Initiatives
i-drop Drag-and-drop from browsersDesignXML Design data schemaRedlineXML Design-related markup schemaLandXML Land development schemaaecXML Architectural schemapXML Catalog-publishing schemayXML …
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
Q & A
top related