Reputation: 2046
My stylesheet below appears to match all text data in the document and I'm looking to target the one richtext element only and iterate through each run element under each par element.
XML:
<?xml version='1.0' encoding='utf-8'?>
<document xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.lotus.com/dxl xmlschemas/domino_8_5_3.xsd'
xmlns='http://www.lotus.com/dxl' version='8.5' maintenanceversion='3.0' replicaid='934850394858534'
form='formreq'>
<noteinfo noteid='234234' unid='02934802938402934023942934' sequence='11'>
<created><datetime dst='true'>20130510T150111,26-05</datetime></created>
<modified><datetime dst='true'>20130513T095937,29-05</datetime></modified>
<revised><datetime dst='true'>20130513T095946,19-05</datetime></revised>
<lastaccessed><datetime dst='true'>20130513T093454,28-05</datetime></lastaccessed>
<addedtofile><datetime dst='true'>20130510T150342,15-05</datetime></addedtofile></noteinfo>
<item name="criteria">
<richtext>
<pardef id='1' leftmargin='0.0500in' rightmargin='97%' keepwithnext='true' keeptogether='true'/>
<par def='1'><run><font style='bold' name='Arial' pitch='variable' truetype='true' familyid='20'/>This is a test.</run></par>
<par def='1'><run><font style='bold' name='Arial' pitch='variable' truetype='true' familyid='20'/>And this is another test.</run></par>
</richtext>
</item>
</document>
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dxl="http://www.lotus.com/dxl" >
<xsl:template match="dxl:document/dxl:item[@name='criteria']/dxl:richtext">
<div id="criteria">
<xsl:for-each select="par">
<xsl:for-each select="run">
<xsl:text>It worked!</xsl:text>
</xsl:for-each>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
I feel for the matching that it's a namespace issue. Also I've tried this on a few different transform engines and receive the same result of:
<?xml version="1.0"?>
20130510T150111,26-05
20130513T095937,29-05
20130513T095946,19-05
20130513T093454,28-05
20130510T150342,15-05
<div xmlns:dxl="http://www.lotus.com/dxl" id="criteria"/>
I'm uncertain as to why the datetime stamps are even matching since that's not part of my match criteria.
A tool to help real-time testing is available at http://www.online-toolz.com/tools/xslt-transformation.php
Upvotes: 0
Views: 244
Reputation: 9627
There is no problem with the namespaces. Reason for this behavior are the default template rules (or better saied: Built-in Template Rules. Some small changes to your xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dxl="http://www.lotus.com/dxl" >
<xsl:template match="dxl:richtext">
<div id="criteria">
<xsl:for-each select="dxl:par">
<xsl:for-each select="dxl:run">
<xsl:text>It worked!</xsl:text>
</xsl:for-each>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="dxl:document/dxl:item[@name='criteria']/dxl:richtext" />
</xsl:template>
</xsl:stylesheet>
Will output the following:
<?xml version="1.0"?>
<div xmlns:dxl="http://www.lotus.com/dxl" id="criteria">It worked!It worked!</div>
Upvotes: 3