SlideShare a Scribd company logo
1 of 29
Advanced XPath and XSLT Reuven Weiser, Suite Solutions
Who am I? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is Suite Solutions? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is XPath? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basic Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basic Example From commons.xsl: <xsl:template  match= &quot;*[contains(@class,' topic/fig ')]&quot; > <fo:block  xsl:use-attribute-sets= &quot;fig&quot;  id= &quot;{@id}&quot; > <xsl:apply-templates  select= &quot;*[not(contains(@class,' topic/title '))]&quot; /> <xsl:apply-templates  select= &quot;*[contains(@class,' topic/title ')]&quot; /> </fo:block> </xsl:template>
XPath Axes
XPath Abbreviations Expression Description Nodename Selects named node / Selects from the root node (start of expression) or the current node // Selects any descendant of the root node (start of expression) or the current node . Selects the current node .. Selects the parent of the current node @ Selects attributes * Wildcard – matches any element node() Matches any node of any kind [ ] Brackets that contain a predicate, which is used to find a specific node
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
List Numbering Goal: A client wants <ol>s in <fig>s to be uppercase-lettered, and sub-<ol>s to be lowercase-lettered Solution: <xsl:choose> <xsl:when  test= &quot;ancestor::*[contains(@class, ' topic/fig ')]&quot; > <xsl:number  format= &quot;A&quot; /> </xsl:when> <xsl:when  test= &quot;count(ancestor::*[contains(@class, ' topic/ol ')]) > 1&quot; > <xsl:number  format= &quot;a&quot; /> </xsl:when> <xsl:otherwise> <xsl:number/> </xsl:otherwise> </xsl:choose>
List Numbering Technique Note Instead of: <xsl:when  test= &quot;ancestor::*[contains(@class, ' topic/fig ')]&quot; > We could say: <xsl:when  test= &quot;ancestor::fig&quot; > But: That wouldn’t account for specialization!
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Trademarks and current() Goal: A client wants the trademark symbol to appear only on the first usage of each trademark Solution 1: <xsl:variable  name= &quot;trademark&quot;   select= &quot;@trademark&quot; /> <xsl:if  test= &quot;not(preceding::*[contains(@class, ' topic/tm ') and @trademark =  $trademark)&quot; > ... </xsl:if> Solution 2 (XPath 2.0): <xsl:if  test= &quot;not(preceding::*[contains(@class, ' topic/tm ') and @trademark =  current()/@trademark)&quot; > ... </xsl:if>
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Custom Functions Goal: A client wants to convert certain text strings to  Title Case Solution: <xsl:stylesheet  xmlns:xsl= &quot;http://www.w3.org/1999/XSL/Transform&quot;    xmlns:ss= &quot;http://www.suite-sol.com&quot;  version= &quot;1.1&quot; > <xsl:function  name= &quot;ss:first-upper-case&quot; >   <xsl:param   name= &quot;string&quot; />   <xsl:value-of  select= &quot;concat(upper-case(substring($string, 1, 1)),  lower-case(substring($string, 2)))&quot; /> </xsl:function>
Custom Functions Goal: A client to convert certain text strings to  Title Case Solution (continued): <xsl:function  name= &quot;ss:title-case&quot; >   <xsl:param   name= &quot;string&quot; />   <xsl:choose>   <xsl:when  test= &quot;contains($string, ' ')&quot; >   <xsl:value-of  select= &quot;concat(ss:first-upper-case(substring-before($string, ' ')), ' ',    ss:title-case(substring-after($string), ' '))&quot; />   </xsl:when>   <xsl:otherwise>   <xsl:value-of  select= &quot;ss:first-upper-case($string)&quot; />   </xsl:otherwise>   </xsl:choose> </xsl:function> <xsl:value-of  select= &quot;ss:title-case($stringToConvert)&quot; />
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
tokenize() Goal: A client wants to check for one outputclass (“border”) among many Challenge: There may also be a “borderless” outputclass, and the outputclass may appear among others (“border other”, “other border”, “otherA border otherB”) Solution 1: <xsl:if  test= &quot;(@outputclass = 'border') or starts-with(@outputclass, 'border ')  or contains(@outputclass, ' border ')  or (substring(@outputclass, string-length(@outputclass)-6, 7)= ' border')&quot; >   <xsl:attribute  name= &quot;border&quot; > 1pt solid black </xsl:attribute> </xsl:if>
tokenize() Goal: A client wants to check for one outputclass (“border”) among many Challenge: There may also be a “borderless” outputclass, and the outputclass may appear among others (“border other”, “other border”, “otherA border otherB”) Solution 2 (XPath 2.0): <xsl:if  test= &quot;tokenize(@outputclass, ' ')[. = 'border']&quot; >   <xsl:attribute  name= &quot;border&quot; > 1pt solid black </xsl:attribute> </xsl:if>
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Keys Trademark Revisited Goal: A client wants the trademark symbol to appear only on the first usage of each trademark, but doesn’t want to take the performance hit of searching through the entire document each and every time a <tm> is processed Solution: <xsl:key  name= &quot;tm&quot;   match= &quot;*[contains(@class, ' topic/tm ')]&quot;  use= &quot;@trademark&quot; /> <xsl:if  test= &quot;generate-id(.) = generate-id(key('tm', @trademark)[1])&quot; > … </xsl:if>
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Grouping Goal: A client wants to group child links by type stage1.xml: <linkpool  class= &quot;- topic/linkpool &quot; >   <link  class= &quot;- topic/link &quot;  role= &quot;child&quot;  type= &quot;concept&quot; >   <linktext  class= &quot;- topic/linktext &quot; > Concept One </linktext>   <desc  class= &quot;- topic/desc &quot; > This is a concept topic. </desc>   </link>   <link  class= &quot;- topic/link &quot;  role= &quot;child&quot;  type= &quot;reference&quot; >   <linktext  class= &quot;- topic/linktext &quot; > Reference One </linktext>   <desc  class= &quot;- topic/desc &quot; > This is a reference topic. </desc>   </link>   <link  class= &quot;- topic/link &quot;  role= &quot;child&quot;  type= &quot;concept&quot; >   <linktext  class= &quot;- topic/linktext &quot; > Concept Two </linktext>   <desc  class= &quot;- topic/desc &quot; > This is another concept topic. </desc>   </link> </linkpool>
Grouping Solution 1 – Muenchian Method: <xsl:key  name= &quot;child-links&quot;  match= &quot;*[contains(@class, ' topic/link ') and @role='child']&quot;  use= &quot;@type&quot; />   <xsl:for-each  select= &quot;*[contains(@class, ' topic/link ') and @role = 'child'] [generate-id(.) = generate-id(key('child-links', @type)[1])&quot; >   <fo:block>   <xsl:value-of  select= &quot;ss:first-upper-case(@type)&quot; />   </fo:block>     <xsl:for-each  select= &quot;key('child-links', @type)&quot; > ...   </xsl:for-each>  </xsl:for-each>
Grouping Solution 2 (XPath 2.0): <xsl:for-each-group  select= &quot;*[contains(@class, ' topic/link ') and @role = 'child']&quot;   group-by= &quot;@type&quot; >   <fo:block>   <xsl:value-of  select= &quot;ss:first-upper-case(current-grouping-key())&quot; />   </fo:block>     <xsl:for-each  select= &quot;current-group()&quot; > ...   </xsl:for-each> </xsl:for-each-group>
Main Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
End of Advanced XPATH ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARStephan Schmidt
 
Developing Plugins
Developing PluginsDeveloping Plugins
Developing PluginsSuite Solutions
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPStephan Schmidt
 
Object Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPObject Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPRobertGonzalez
 
The Big Documentation Extravaganza
The Big Documentation ExtravaganzaThe Big Documentation Extravaganza
The Big Documentation ExtravaganzaStephan Schmidt
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHPStephan Schmidt
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Stephan Schmidt
 
PEAR For The Masses
PEAR For The MassesPEAR For The Masses
PEAR For The MassesStephan Schmidt
 
Session Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersStephan Schmidt
 
Open Power Template 2 presentation
Open Power Template 2 presentationOpen Power Template 2 presentation
Open Power Template 2 presentationTomasz Jędrzejewski
 
Lotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLLotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLdominion
 
Design Tools Html Xhtml
Design Tools Html XhtmlDesign Tools Html Xhtml
Design Tools Html XhtmlAhsan Uddin Shan
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9isadorta
 

What's hot (20)

XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEAR
 
Developing Plugins
Developing PluginsDeveloping Plugins
Developing Plugins
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
Object Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHPObject Oriented Design Patterns for PHP
Object Oriented Design Patterns for PHP
 
The Big Documentation Extravaganza
The Big Documentation ExtravaganzaThe Big Documentation Extravaganza
The Big Documentation Extravaganza
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHP
 
Xhtml
XhtmlXhtml
Xhtml
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5
 
PEAR For The Masses
PEAR For The MassesPEAR For The Masses
PEAR For The Masses
 
XML and PHP 5
XML and PHP 5XML and PHP 5
XML and PHP 5
 
Session Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several Servers
 
Open Power Template 2 presentation
Open Power Template 2 presentationOpen Power Template 2 presentation
Open Power Template 2 presentation
 
CSS
CSSCSS
CSS
 
Design attern in php
Design attern in phpDesign attern in php
Design attern in php
 
Lotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLLotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXL
 
PHP MySQL
PHP MySQLPHP MySQL
PHP MySQL
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Design Tools Html Xhtml
Design Tools Html XhtmlDesign Tools Html Xhtml
Design Tools Html Xhtml
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
 
Xhtml
XhtmlXhtml
Xhtml
 

Similar to AdvancedXPath

3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schemagauravashq
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)gauravashq
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
Struts2
Struts2Struts2
Struts2yuvalb
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Languageyht4ever
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with JavaBG Java EE Course
 
Digital + Container List
Digital + Container ListDigital + Container List
Digital + Container Listguest53eac8
 
HTML (Basic to Advance)
HTML (Basic to Advance)HTML (Basic to Advance)
HTML (Basic to Advance)Coder Tech
 
Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xslhapy
 
StrategiesForUsingMetadata
StrategiesForUsingMetadataStrategiesForUsingMetadata
StrategiesForUsingMetadataSuite Solutions
 
Play Template Engine Based On Scala
Play Template Engine Based On ScalaPlay Template Engine Based On Scala
Play Template Engine Based On ScalaKnoldus Inc.
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18HUST
 
Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-htmlRafael Alvarado
 

Similar to AdvancedXPath (20)

Xml
XmlXml
Xml
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
 
Struts2
Struts2Struts2
Struts2
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Struts2
Struts2Struts2
Struts2
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
 
Web Designing
Web DesigningWeb Designing
Web Designing
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
Digital + Container List
Digital + Container ListDigital + Container List
Digital + Container List
 
HTML (Basic to Advance)
HTML (Basic to Advance)HTML (Basic to Advance)
HTML (Basic to Advance)
 
Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xsl
 
StrategiesForUsingMetadata
StrategiesForUsingMetadataStrategiesForUsingMetadata
StrategiesForUsingMetadata
 
What is xml
What is xmlWhat is xml
What is xml
 
Play Template Engine Based On Scala
Play Template Engine Based On ScalaPlay Template Engine Based On Scala
Play Template Engine Based On Scala
 
Advance HTML
Advance HTMLAdvance HTML
Advance HTML
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
 
Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-html
 

More from Suite Solutions

SuiteHelp 4.0: Latest Features in Enterprise Webhelp
SuiteHelp 4.0: Latest Features in Enterprise WebhelpSuiteHelp 4.0: Latest Features in Enterprise Webhelp
SuiteHelp 4.0: Latest Features in Enterprise WebhelpSuite Solutions
 
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...Suite Solutions
 
Increasing Findability with Subject Schemes (Advanced DITA Webinar)
Increasing Findability with Subject Schemes (Advanced DITA Webinar)Increasing Findability with Subject Schemes (Advanced DITA Webinar)
Increasing Findability with Subject Schemes (Advanced DITA Webinar)Suite Solutions
 
SuiteHelp 3.2.5 Latest Features
SuiteHelp 3.2.5 Latest FeaturesSuiteHelp 3.2.5 Latest Features
SuiteHelp 3.2.5 Latest FeaturesSuite Solutions
 
Using Taxonomy for Customer-centric Dynamic Publishing
Using Taxonomy for Customer-centric Dynamic PublishingUsing Taxonomy for Customer-centric Dynamic Publishing
Using Taxonomy for Customer-centric Dynamic PublishingSuite Solutions
 
DITA Quick Start Webinar: Defining Your Style Sheet Requirements
DITA Quick Start Webinar: Defining Your Style Sheet RequirementsDITA Quick Start Webinar: Defining Your Style Sheet Requirements
DITA Quick Start Webinar: Defining Your Style Sheet RequirementsSuite Solutions
 
DITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanDITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanSuite Solutions
 
DITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanDITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanSuite Solutions
 
DITA Quick Start: System Architecture of a Basic DITA Toolset
DITA Quick Start: System Architecture of a Basic DITA ToolsetDITA Quick Start: System Architecture of a Basic DITA Toolset
DITA Quick Start: System Architecture of a Basic DITA ToolsetSuite Solutions
 
DITA Quick Start Webinar Series: Getting Started with the DITA Open Toolkit
DITA Quick Start Webinar Series: Getting Started with the DITA Open ToolkitDITA Quick Start Webinar Series: Getting Started with the DITA Open Toolkit
DITA Quick Start Webinar Series: Getting Started with the DITA Open ToolkitSuite Solutions
 
DITA Quick Start Webinar Series: Getting Started with Information Architecture
DITA Quick Start Webinar Series: Getting Started with Information ArchitectureDITA Quick Start Webinar Series: Getting Started with Information Architecture
DITA Quick Start Webinar Series: Getting Started with Information ArchitectureSuite Solutions
 
Introduction to S1000D
Introduction to S1000DIntroduction to S1000D
Introduction to S1000DSuite Solutions
 
DITA Quick Start for Authors Part II
DITA Quick Start for Authors Part IIDITA Quick Start for Authors Part II
DITA Quick Start for Authors Part IISuite Solutions
 
DITA Quick Start for Authors - Part I
DITA Quick Start for Authors - Part IDITA Quick Start for Authors - Part I
DITA Quick Start for Authors - Part ISuite Solutions
 
Suite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Solutions
 
Overview of SuiteHelp 3.1 for DITA
Overview of SuiteHelp 3.1 for DITAOverview of SuiteHelp 3.1 for DITA
Overview of SuiteHelp 3.1 for DITASuite Solutions
 
Dita ot pipeline webinar
Dita ot pipeline webinarDita ot pipeline webinar
Dita ot pipeline webinarSuite Solutions
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsSuite Solutions
 
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...Suite Solutions
 

More from Suite Solutions (20)

SuiteHelp 4.0: Latest Features in Enterprise Webhelp
SuiteHelp 4.0: Latest Features in Enterprise WebhelpSuiteHelp 4.0: Latest Features in Enterprise Webhelp
SuiteHelp 4.0: Latest Features in Enterprise Webhelp
 
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...
Moving your Organization up the Knowledge Value Chain (Proposal for Lavacon 2...
 
Increasing Findability with Subject Schemes (Advanced DITA Webinar)
Increasing Findability with Subject Schemes (Advanced DITA Webinar)Increasing Findability with Subject Schemes (Advanced DITA Webinar)
Increasing Findability with Subject Schemes (Advanced DITA Webinar)
 
SuiteHelp 3.2.5 Latest Features
SuiteHelp 3.2.5 Latest FeaturesSuiteHelp 3.2.5 Latest Features
SuiteHelp 3.2.5 Latest Features
 
Using Taxonomy for Customer-centric Dynamic Publishing
Using Taxonomy for Customer-centric Dynamic PublishingUsing Taxonomy for Customer-centric Dynamic Publishing
Using Taxonomy for Customer-centric Dynamic Publishing
 
DITA Quick Start Webinar: Defining Your Style Sheet Requirements
DITA Quick Start Webinar: Defining Your Style Sheet RequirementsDITA Quick Start Webinar: Defining Your Style Sheet Requirements
DITA Quick Start Webinar: Defining Your Style Sheet Requirements
 
DITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanDITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project Plan
 
DITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project PlanDITA Quick Start Webinar Series: Building a Project Plan
DITA Quick Start Webinar Series: Building a Project Plan
 
DITA Quick Start: System Architecture of a Basic DITA Toolset
DITA Quick Start: System Architecture of a Basic DITA ToolsetDITA Quick Start: System Architecture of a Basic DITA Toolset
DITA Quick Start: System Architecture of a Basic DITA Toolset
 
DITA Quick Start Webinar Series: Getting Started with the DITA Open Toolkit
DITA Quick Start Webinar Series: Getting Started with the DITA Open ToolkitDITA Quick Start Webinar Series: Getting Started with the DITA Open Toolkit
DITA Quick Start Webinar Series: Getting Started with the DITA Open Toolkit
 
DITA Quick Start Webinar Series: Getting Started with Information Architecture
DITA Quick Start Webinar Series: Getting Started with Information ArchitectureDITA Quick Start Webinar Series: Getting Started with Information Architecture
DITA Quick Start Webinar Series: Getting Started with Information Architecture
 
Introduction to S1000D
Introduction to S1000DIntroduction to S1000D
Introduction to S1000D
 
DITA Quick Start for Authors Part II
DITA Quick Start for Authors Part IIDITA Quick Start for Authors Part II
DITA Quick Start for Authors Part II
 
DITA Quick Start for Authors - Part I
DITA Quick Start for Authors - Part IDITA Quick Start for Authors - Part I
DITA Quick Start for Authors - Part I
 
Suite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp Output
 
Overview of SuiteHelp 3.1 for DITA
Overview of SuiteHelp 3.1 for DITAOverview of SuiteHelp 3.1 for DITA
Overview of SuiteHelp 3.1 for DITA
 
Svg and graphics
Svg and graphicsSvg and graphics
Svg and graphics
 
Dita ot pipeline webinar
Dita ot pipeline webinarDita ot pipeline webinar
Dita ot pipeline webinar
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
 
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...
Understanding and Configuring the FO Plug-in for Generating PDF Files: Part I...
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

AdvancedXPath

  • 1. Advanced XPath and XSLT Reuven Weiser, Suite Solutions
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Basic Example From commons.xsl: <xsl:template match= &quot;*[contains(@class,' topic/fig ')]&quot; > <fo:block xsl:use-attribute-sets= &quot;fig&quot; id= &quot;{@id}&quot; > <xsl:apply-templates select= &quot;*[not(contains(@class,' topic/title '))]&quot; /> <xsl:apply-templates select= &quot;*[contains(@class,' topic/title ')]&quot; /> </fo:block> </xsl:template>
  • 10. XPath Abbreviations Expression Description Nodename Selects named node / Selects from the root node (start of expression) or the current node // Selects any descendant of the root node (start of expression) or the current node . Selects the current node .. Selects the parent of the current node @ Selects attributes * Wildcard – matches any element node() Matches any node of any kind [ ] Brackets that contain a predicate, which is used to find a specific node
  • 11.
  • 12. List Numbering Goal: A client wants <ol>s in <fig>s to be uppercase-lettered, and sub-<ol>s to be lowercase-lettered Solution: <xsl:choose> <xsl:when test= &quot;ancestor::*[contains(@class, ' topic/fig ')]&quot; > <xsl:number format= &quot;A&quot; /> </xsl:when> <xsl:when test= &quot;count(ancestor::*[contains(@class, ' topic/ol ')]) > 1&quot; > <xsl:number format= &quot;a&quot; /> </xsl:when> <xsl:otherwise> <xsl:number/> </xsl:otherwise> </xsl:choose>
  • 13. List Numbering Technique Note Instead of: <xsl:when test= &quot;ancestor::*[contains(@class, ' topic/fig ')]&quot; > We could say: <xsl:when test= &quot;ancestor::fig&quot; > But: That wouldn’t account for specialization!
  • 14.
  • 15. Trademarks and current() Goal: A client wants the trademark symbol to appear only on the first usage of each trademark Solution 1: <xsl:variable name= &quot;trademark&quot; select= &quot;@trademark&quot; /> <xsl:if test= &quot;not(preceding::*[contains(@class, ' topic/tm ') and @trademark = $trademark)&quot; > ... </xsl:if> Solution 2 (XPath 2.0): <xsl:if test= &quot;not(preceding::*[contains(@class, ' topic/tm ') and @trademark = current()/@trademark)&quot; > ... </xsl:if>
  • 16.
  • 17. Custom Functions Goal: A client wants to convert certain text strings to Title Case Solution: <xsl:stylesheet xmlns:xsl= &quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:ss= &quot;http://www.suite-sol.com&quot; version= &quot;1.1&quot; > <xsl:function name= &quot;ss:first-upper-case&quot; > <xsl:param name= &quot;string&quot; /> <xsl:value-of select= &quot;concat(upper-case(substring($string, 1, 1)), lower-case(substring($string, 2)))&quot; /> </xsl:function>
  • 18. Custom Functions Goal: A client to convert certain text strings to Title Case Solution (continued): <xsl:function name= &quot;ss:title-case&quot; > <xsl:param name= &quot;string&quot; /> <xsl:choose> <xsl:when test= &quot;contains($string, ' ')&quot; > <xsl:value-of select= &quot;concat(ss:first-upper-case(substring-before($string, ' ')), ' ', ss:title-case(substring-after($string), ' '))&quot; /> </xsl:when> <xsl:otherwise> <xsl:value-of select= &quot;ss:first-upper-case($string)&quot; /> </xsl:otherwise> </xsl:choose> </xsl:function> <xsl:value-of select= &quot;ss:title-case($stringToConvert)&quot; />
  • 19.
  • 20. tokenize() Goal: A client wants to check for one outputclass (“border”) among many Challenge: There may also be a “borderless” outputclass, and the outputclass may appear among others (“border other”, “other border”, “otherA border otherB”) Solution 1: <xsl:if test= &quot;(@outputclass = 'border') or starts-with(@outputclass, 'border ') or contains(@outputclass, ' border ') or (substring(@outputclass, string-length(@outputclass)-6, 7)= ' border')&quot; > <xsl:attribute name= &quot;border&quot; > 1pt solid black </xsl:attribute> </xsl:if>
  • 21. tokenize() Goal: A client wants to check for one outputclass (“border”) among many Challenge: There may also be a “borderless” outputclass, and the outputclass may appear among others (“border other”, “other border”, “otherA border otherB”) Solution 2 (XPath 2.0): <xsl:if test= &quot;tokenize(@outputclass, ' ')[. = 'border']&quot; > <xsl:attribute name= &quot;border&quot; > 1pt solid black </xsl:attribute> </xsl:if>
  • 22.
  • 23. Keys Trademark Revisited Goal: A client wants the trademark symbol to appear only on the first usage of each trademark, but doesn’t want to take the performance hit of searching through the entire document each and every time a <tm> is processed Solution: <xsl:key name= &quot;tm&quot; match= &quot;*[contains(@class, ' topic/tm ')]&quot; use= &quot;@trademark&quot; /> <xsl:if test= &quot;generate-id(.) = generate-id(key('tm', @trademark)[1])&quot; > … </xsl:if>
  • 24.
  • 25. Grouping Goal: A client wants to group child links by type stage1.xml: <linkpool class= &quot;- topic/linkpool &quot; > <link class= &quot;- topic/link &quot; role= &quot;child&quot; type= &quot;concept&quot; > <linktext class= &quot;- topic/linktext &quot; > Concept One </linktext> <desc class= &quot;- topic/desc &quot; > This is a concept topic. </desc> </link> <link class= &quot;- topic/link &quot; role= &quot;child&quot; type= &quot;reference&quot; > <linktext class= &quot;- topic/linktext &quot; > Reference One </linktext> <desc class= &quot;- topic/desc &quot; > This is a reference topic. </desc> </link> <link class= &quot;- topic/link &quot; role= &quot;child&quot; type= &quot;concept&quot; > <linktext class= &quot;- topic/linktext &quot; > Concept Two </linktext> <desc class= &quot;- topic/desc &quot; > This is another concept topic. </desc> </link> </linkpool>
  • 26. Grouping Solution 1 – Muenchian Method: <xsl:key name= &quot;child-links&quot; match= &quot;*[contains(@class, ' topic/link ') and @role='child']&quot; use= &quot;@type&quot; /> <xsl:for-each select= &quot;*[contains(@class, ' topic/link ') and @role = 'child'] [generate-id(.) = generate-id(key('child-links', @type)[1])&quot; > <fo:block> <xsl:value-of select= &quot;ss:first-upper-case(@type)&quot; /> </fo:block> <xsl:for-each select= &quot;key('child-links', @type)&quot; > ... </xsl:for-each> </xsl:for-each>
  • 27. Grouping Solution 2 (XPath 2.0): <xsl:for-each-group select= &quot;*[contains(@class, ' topic/link ') and @role = 'child']&quot; group-by= &quot;@type&quot; > <fo:block> <xsl:value-of select= &quot;ss:first-upper-case(current-grouping-key())&quot; /> </fo:block> <xsl:for-each select= &quot;current-group()&quot; > ... </xsl:for-each> </xsl:for-each-group>
  • 28.
  • 29.

Editor's Notes

  1. Suite Solutions: DITA Quick Start Training for Authors iDTP, March 16-18, 2009