Link to home
Start Free TrialLog in
Avatar of mmalik15
mmalik15

asked on

how to seperate each entry of a node with a full stop (if one is not already present) using xslt 1.0 or xpath 1.0

hi experts,

My xml is attached. My requirement is to separate each entry of <abst> with full stop (if one not already present) and a space. I have tried something like this in xslt but it does not seem to work

<xsl:stylesheet version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 
  <xsl:template match="/">
    <records>
      <xsl:for-each select="/ListRecords/record">
        <record>
         
          <body>
          <xsl:for-each select="metadata/ovidrec/abst" >
            <xsl:value-of select='concat(.," ")'   />
            </xsl:for-each>
          </body>
         
          </record>
         
          </xsl:for-each>
          </records>
         
          </xsl:template>
</xsl:stylesheet>


 
<?xml version="1.0" encoding="UTF-8"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
	<responseDate>2011-08-12 05:55:03</responseDate>
	<request verb="ListRecords">http://an.oa.org/OAI-script</request>
	<ListRecords>
		<record>
			<header>
				<identifier>ovid:/bib/cochdb/CD000008</identifier>
				<datestamp>2011-08-12</datestamp>
				<setSpec>BibDB:coch</setSpec>
			</header>
			<metadata>
				<ovidrec xmlns="http://ovid.com/rec/elements/1.0/" xsi:schemaLocation="http://ovid.com/rec/elements/1.0/">
					<acno>CD000008</acno>
					<auts>McCarney, Robert W</auts>
					<auts>Brinkhaus, Benno</auts>
					<auts>Lasserson, Toby J</auts>
					<auts>Linde, Klaus</auts>
					<year>2009</year>
					<doct>Reviews</doct>
					<titl>Acupuncture for chronic asthma</titl>
					<suba>Chronic asthma - non-pharmacological interventions</suba>
					<suba>Acupuncture, homoeopathy and herbal remedies</suba>
					<suba>Humans</suba>
					<suba>*Acupuncture Therapy</suba>
					<suba>*Asthma/th [therapy]</suba>
					<suba>Chronic Disease</suba>
					<suba>Randomized Controlled Trials as Topic</suba>
					<jour>Cochrane Database of Systematic Reviews</jour>
					<lang>English</lang>
					<issu>3</issu>
					<upcd>20093</upcd>
					<grpn>Cochrane Airways Group</grpn>
					<pubt>Systematic Review</pubt>
					<ftlk>CD000008</ftlk>
					<abst>Background</abst>
					<abst>Acupuncture has traditionally been used to treat asthma in China and is used increasingly for this purpose internationally.</abst>
					<abst>Objectives</abst>
					<abst>The objective of this review was to assess the effects of acupuncture for the treatment of asthma or asthma-like symptoms.</abst>
					<abst>Search strategy</abst>
					<abst>We searched the Cochrane Airways Group Specialised Register (last searched August 2008), the Cochrane Complementary Medicine Field trials register, AMED, and reference lists of articles. We also contacted trialists and researchers in the field of complementary and alternative medical research.</abst>
					<abst>Selection criteria</abst>
					<abst>Randomised and possibly randomised trials using needle acupuncture or other forms of stimulation of acupuncture. Any form of control treatment was considered (no treatment in addition to conventional asthma treatment, sham or placebo interventions, active comparator interventions). Studies were included provided outcome was assessed at one week or more.</abst>
					<abst>Data collection and analysis</abst>
					<abst>At least two reviewers independently assessed trial quality. A reviewer experienced in acupuncture assessed the adequacy of the active and sham acupuncture used in the studies. Study authors were contacted for missing information.</abst>
					<abst>Main results</abst>
					<abst>Twelve studies met the inclusion criteria recruiting 350 participants. Trial reporting was poor and trial quality was deemed inadequate to generalise findings. There was variation in the type of active and sham acupuncture, the outcomes measured and time-points presented. The points used in the sham arm of some studies are used for the treatment of asthma according to traditional Chinese medicine. Two studies used individualised treatment strategies and one study used a combination strategy of formula acupuncture with the addition of individualised points. No statistically significant or clinically relevant effects were found for acupuncture compared to sham acupuncture. Data from two small studies were pooled for lung function (post-treatment FEV1): Standardised Mean Difference 0.12, 95% confidence interval -0.31 to 0.55).</abst>
					<abst>Authors' conclusions</abst>
					<abst>There is not enough evidence to make recommendations about the value of acupuncture in asthma treatment. Further research needs to consider the complexities and different types of acupuncture.</abst>
				</ovidrec>
			</metadata>
		</record>
		</ListRecords>
</OAI-PMH>

Open in new window

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image


<xsl:stylesheet version="1.0"   
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:oai="http://www.openarchives.org/OAI/2.0/"
    xmlns:ovid="http://ovid.com/rec/elements/1.0/"
    exclude-result-prefixes="oai ovid">
    
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    
    <xsl:template match="/">
        <records>
            <xsl:apply-templates select="//oai:ListRecords/oai:record"/>
        </records>
        
    </xsl:template>
    
    <xsl:template match="oai:record">
        <record>
            <body>
                <xsl:apply-templates select="oai:metadata/ovid:ovidrec/ovid:abst" />
            </body>
        </record>
    </xsl:template>
    
    <xsl:template match="ovid:abst">
        <xsl:if test="not(position() = 1)">
            <xsl:text> </xsl:text>
        </xsl:if>
        <xsl:value-of select="substring(., 1, string-length(.) - 1)"/>
        <xsl:value-of select="translate(substring(., string-length(.)), '.', '')"/>
        <xsl:text>.</xsl:text>
    </xsl:template>
</xsl:stylesheet>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmalik15
mmalik15

ASKER

perfect!