xml - More XSLT and Namespace/Matching Issues -


my stylesheet below appears match text data in document , i'm looking target 1 richtext element , 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 test.</run></par>             <par def='1'><run><font style='bold' name='arial' pitch='variable' truetype='true' familyid='20'/>and 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 matching it's namespace issue. i've tried on few different transform engines , receive 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 why datetime stamps matching since that's not part of match criteria.

a tool real-time testing available @ http://www.online-toolz.com/tools/xslt-transformation.php

there no problem namespaces. reason behavior default template rules (or better saied: built-in template rules. small changes 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 following:

<?xml version="1.0"?> <div xmlns:dxl="http://www.lotus.com/dxl" id="criteria">it worked!it worked!</div> 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -