[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT Help

Subject: Re: XSLT Help
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 19 Oct 2010 15:17:48 +0100
Re:  XSLT Help
In XSLT 2.0:

<xsl:template match="element-citation">
<xsl:for-each-group select="*" group-adjacent="node-name()">
<xsl:choose>
<xsl:when test="self::name">
<author-grp><xsl:copy-of select="current-group()"/></author-grp>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>

Michael Kay
Saxonica

On 19/10/2010 15:10, chirag matkar wrote:
Hello Everybody ,

Here is my Doubt

Input is-
<ref id="B1">
         <label>1</label>
         <element-citation publication-type="journal">
             <name>
               <surname>Shah</surname>
               <given-names>NC</given-names>
             </name>
           <article-title>Viewpoint: Consultation time&#x2014;time for
a change? Still the&#x201C;perfunctory work of perfunctory
men!&#x201D;</article-title>
           <source>Br J Gen Pract</source>
           <year>1999</year>
           <volume>49</volume>
           <fpage>497</fpage>
         </element-citation>
       </ref>
       <ref id="B2">
         <label>2</label>
         <element-citation publication-type="journal">
             <name>
               <surname>Mechanic</surname>
               <given-names>D</given-names>
             </name>
           <article-title>How should hamsters run? Some observations
about sufficient patient time in primary care</article-title>
           <source>BMJ</source>
           <year>2001</year>
           <volume>323</volume>
           <fpage>266</fpage>
           <lpage>268</lpage>
           <pub-id pub-id-type="pmid">11485957</pub-id>
         </element-citation>
       </ref>
       <ref id="B3">
         <label>3</label>
         <element-citation publication-type="journal">
             <name>
               <surname>Howie</surname>
               <given-names>JGR</given-names>
             </name>
             <name>
               <surname>Porter</surname>
               <given-names>AMD</given-names>
             </name>
             <name>
               <surname>Heaney</surname>
               <given-names>DJ</given-names>
             </name>
             <name>
               <surname>Hopton</surname>
               <given-names>JL</given-names>
             </name>
           <article-title>Long to short consultation ratio: a proxy
measure of quality of care for general practice</article-title>
           <source>Br J Gen Pract</source>
           <year>1991</year>
           <volume>41</volume>
           <fpage>48</fpage>
           <lpage>54</lpage>
           <pub-id pub-id-type="pmid">2031735</pub-id>
         </element-citation>
       </ref>
       <ref id="B4">
         <label>4</label>
         <element-citation publication-type="journal">
             <name>
               <surname>Howie</surname>
               <given-names>JGR</given-names>
             </name>
             <name>
               <surname>Heaney</surname>
               <given-names>DJ</given-names>
             </name>
             <name>
               <surname>Maxwell</surname>
               <given-names>M</given-names>
             </name>
             <name>
               <surname>Walker</surname>
               <given-names>JJ</given-names>
             </name>
             <name>
               <surname>Freeman</surname>
               <given-names>GK</given-names>
             </name>
             <name>
               <surname>Rai</surname>
               <given-names>H</given-names>
             </name>
           <article-title>Quality at general practice consultations:
cross-sectional survey</article-title>
           <source>BMJ</source>
           <year>1999</year>
           <volume>319</volume>
           <fpage>738</fpage>
           <lpage>743</lpage>
           <pub-id pub-id-type="pmid">10487999</pub-id>
         </element-citation>
       </ref>
Many references after this too


Desired output is al the name tags inside authorgrp tag


<authorgrp>
<name>
               <surname>Mechanic</surname>
               <given-names>D</given-names>
             </name>
</authorgrp>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.