Presentation is loading. Please wait.

Presentation is loading. Please wait.

XSLT and Open XML.

Similar presentations


Presentation on theme: "XSLT and Open XML."— Presentation transcript:

1 XSLT and Open XML

2 Disclaimer The information contained in this slide deck represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This slide deck is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this slide deck may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this slide deck. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this slide deck does not give you any license to these patents, trademarks, copyrights, or other intellectual property. Unless otherwise noted, the example companies, organizations, products, domain names, addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, address, logo, person, place or event is intended or should be inferred. © 2006 Microsoft Corporation. All rights reserved. Microsoft, 2007 Microsoft Office System, .NET Framework 3.0, Visual Studio, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

3 Overview Working with XSLT in .NET XSLT Business Scenarios

4 Lesson: Working with XSLT in .NET
XSLT Architecture in the .NET Framework Rich Features of the XSLT Infrastructure Passing Values to the XSLT Transformation Working with Extension Objects Pointers on Open XML Transformations

5 XSLT Architecture in the .NET Framework
XmlDocument Url XPathDocument XmlReader XPathNavigator XslCompiledTransform.Load() XSLT XslCompiledTransform.Transform() XmReader XmlWriter TextWriter Stream Url XmlDocument XPathDocument XPathNavigator File

6 Rich Features of the XSLT Infrastructure
Pass .NET values to the XSLT engine using the XsltArgumentList.AddParam() method Call .NET methods from inside the XSLT using Extension Objects Available through the XsltArgumentList.AddExtensionObject() method Render XSLT results out on the web using the ASP.NET XmlControl

7 Passing Values to the XSLT Transformation
XSLT style sheets can receive parameters <xsl:param name=“discount" /> ... <xsl:value-of – * $discount)"/> String Boolean Double XPathNavigator XPathNodeIterator XslCompiledTransform transform = new XslCompiledTransform(); transform.Load("sample.xslt"); XsltArgumentList arguments = new XsltArgumentList(); arguments.AddParam(“discount", "", 0.30); using (FileStream fs = new FileStream("output.txt")) { transform.Transform(document, arguments, fs); }

8 Working with Extension Objects
An extension object is a .NET object referenced from inside the style sheet. Each method is exposed as a custom function class MyClass { public string MyMethod( int value) { … } } <xsl:stylesheet … xmlns:myNs=“urn:myUrn”> <xsl:value-of select=“myNs:MyMethod(123)” /> </xsl:stylesheet>

9 Pointers on Open XML Transformations
When transforming from Open XML Access other document parts with the XSLT document() function <xsl:for-each select="document(other.xml)/my/element"> Resolve paths to external resources using a custom XmlResolver class class SampleResolver : XmlResolver { Package _package; public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) PackagePart part = _package.GetPart(absoluteUri); return part.GetStream(); } You can specify 2 resolvers in the XslCompiledTransform class. One is for import and include tags, specified with the Load method. The other is for document() function calls from inside the xslt, specify this resolver using 1 overload of Transform, the last in intellisense.

10 Lesson: XSLT Business Scenarios
Custom Data to Open XML Open XML to ODF WordprocessingML to XSL-FO WordprocessingML to HTML

11 XSL-FO RTF ODF PDF HTML XPS Open XML SQL XML ODF

12 Review Working with XSLT in .NET XSLT Business Scenarios

13


Download ppt "XSLT and Open XML."

Similar presentations


Ads by Google