?
Solved

how to put a full stop and space after each node where there isn't already a full stop or a colon.

Posted on 2011-10-14
9
Medium Priority
?
233 Views
Last Modified: 2012-05-12
Contents of <styi>
Concatenate entries. Put space between each entry if one not already present. Put a full stop where there isn't already a full stop or a colon.
Remove <ovid:B> </ovid:B> tags
Remove  <styi><ovid:B>Index terms: </ovid:B></styi>

For example:
<styi><ovid:B>Authors' objectives: </ovid:B></styi>
  <styi>To summarise the current scientific knowledge on the causes, diagnosis and treatment of back pain.</styi>
  <styi><ovid:B>Authors' conclusions: </ovid:B></styi>
  <styi>It is important to carefully investigate and document information on patients suffering from back pain to ensure that the problems are not being caused by an injury or organic disease.</styi>
  <styi><ovid:B>Index terms: </ovid:B></styi>

OUTPUT

"Authors' objectives: To summarise the current scientific knowledge on the causes, diagnosis and treatment of back pain. Authors' conclusions: It is important to carefully investigate and document information on patients suffering from back pain to ensure that the problems are not being caused by an injury or organic disease."
<?xml version="1.0"?>
<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>2010-05-06T20:47:02Z</responseDate>
	<request verb="ListRecords">http://an.oa.org/OAI-script</request>
	<ListRecords>
		<record>
			<header>
				<identifier>ovid:/bib/clhtadb/HTA-31995000000</identifier>
				<datestamp>1904-01-01</datestamp>
				<setSpec>BibDB:clhta</setSpec>
			</header>
			<metadata>
				<ovidrec xmlns="http://ovid.com/rec/elements/1.0/" xsi:schemaLocation="http://ovid.com/rec/elements/1.0/ http://ovidsp.tx.ovid.com/oai-pmh/OAI/2.0/ovid_rec.xsd">
					<acno>HTA-31995000000</acno>
					<auts>Marshall, D</auts>
					<year>2010</year>
					<titl>Gallstone therapies (Structured abstract)</titl>
					<suba>Cholecystectomy</suba>
					<suba>Cholecystectomy, Laparoscopic</suba>
					<suba>Cholelithiasis</suba>
					<suba>Laparoscopy</suba>
					<suba>Lithotripsy</suba>
					<issn>1465-1858</issn>
					<issu>2010 Issue 2</issu>
					<entd>Centre for Reviews and Dissemination</entd>
					<revso>John Wiley &amp; Sons, Ltd. Chichester, UK. Division: ST</revso>
					<styi>&lt;ovid:B&gt;Authors&apos; objectives: &lt;/ovid:B&gt;</styi>
					<styi>Comparison of open cholecystectomy, laparoscopic cholecystectomy and gallstone lithotripsy.</styi>
					<styi>&lt;ovid:B&gt;Type of intervention: &lt;/ovid:B&gt;</styi>
					<styi>Treatment</styi>
					<styi>&lt;ovid:B&gt;Searching: &lt;/ovid:B&gt;</styi>
					<styi>Published literature; TA agency documents; hospital-specific costs; government physician payment schedules; manufacturers&apos; data.</styi>
					<styi>&lt;ovid:B&gt;Results: &lt;/ovid:B&gt;</styi>
					<styi>a) No controlled trials of laparoscopic cholecystectomy comparing it with surgical cholecystectomy have been completed. However, it is being adopted at a rapid rate in Canadian hospitals; b) Total treatment costs for the three therapies per case are $3437 (open), $2605 (lap.) and $1631 (lithotripsy). This does not include costs associated with loss of work, and costs due to complications; c) When variables e.g. length of stay, hospital room rates, patient throughput, length of adjunct drug therapy, number of lithotripsy sessions, etc. are changed, the three per-case costs range from $2661 to $5825 (open), $2497 to $3236 (lap.) and $1553 to $7475 (lithotripsy); d) There is no evidence that use of a laser improves outcomes for laparoscopic cholecystectomy; e) Training of surgeons in the laparoscopic procedure may not be adequate.</styi>
					<styi>&lt;ovid:B&gt;Index terms: &lt;/ovid:B&gt;</styi>
					<suml>English</suml>
				</ovidrec>
			</metadata>
		</record>
		<record>
			<header>
				<identifier>ovid:/bib/clhtadb/HTA-31995000001</identifier>
				<datestamp>1904-01-01</datestamp>
				<setSpec>BibDB:clhta</setSpec>
			</header>
			<metadata>
				<ovidrec xmlns="http://ovid.com/rec/elements/1.0/" xsi:schemaLocation="http://ovid.com/rec/elements/1.0/ http://ovidsp.tx.ovid.com/oai-pmh/OAI/2.0/ovid_rec.xsd">
					<acno>HTA-31995000001</acno>
					<auts>Comis, J</auts>
					<year>2010</year>
					<titl>Reuse of single-use cardiac catheters (Structured abstract)</titl>
					<suba>Data Collection</suba>
					<suba>Disposable Equipment/ut [Utilization]</suba>
					<suba>Equipment and Supplies, Hospital</suba>
					<suba>Equipment Safety</suba>
					<suba>Heart Catheterization/is [Instrumentation]</suba>
					<issn>1465-1858</issn>
					<issu>2010 Issue 2</issu>
					<entd>Centre for Reviews and Dissemination</entd>
					<revso>John Wiley &amp; Sons, Ltd. Chichester, UK. Division: ST</revso>
					<styd>Review</styd>
					<styi>&lt;ovid:B&gt;Authors&apos; objectives: &lt;/ovid:B&gt;</styi>
					<styi>To address four issues related to the re-use of diagnostic cardiac catheters and angiography cardiac catheters: risk of infection, functional effectiveness, cost-effectiveness, and liability; request from provincial governments.</styi>
					<styi>&lt;ovid:B&gt;Type of intervention: &lt;/ovid:B&gt;</styi>
					<styi>Medical devices</styi>
					<styi>&lt;ovid:B&gt;Searching: &lt;/ovid:B&gt;</styi>
					<styi>Published literature; government agency documents; cardiac catheterization laboratory staff in hospitals.</styi>
					<styi>&lt;ovid:B&gt;Results: &lt;/ovid:B&gt;</styi>
					<styi>a) The possible increased risk of infection with re-use is a concern; however, there is no conclusive evidence that there is no increased risk; b) Hospitals do not typically have guidelines as to the number of times a catheter can be reused; c) Hospitals that reuse catheters expect volumes of procedures to decrease if they stopped re-using; d) One hospital has estimated an annual saving of $100,000 if catheters are re-used 10 times; e) Patients are not informed if a used catheter is to be used on them. It is possible that this breaches the standard of care according to Canadian law.</styi>
					<styi>&lt;ovid:B&gt;Authors&apos; conclusions: &lt;/ovid:B&gt;</styi>
					<styi>Revising/reprocessing cardiac catheters has not been proven to be safe or unsafe. Since the primary motivation is economic, more hospitals are considering this practice. There still remain issues and questions that need to be addressed before re-use can be considered a safe practice.</styi>
					<styi>&lt;ovid:B&gt;Index terms: &lt;/ovid:B&gt;</styi>
					<suml>English</suml>
				</ovidrec>
			</metadata>
		</record>
			</ListRecords>
</OAI-PMH>

Open in new window

0
Comment
Question by:mmalik15
  • 5
  • 2
  • 2
9 Comments
 
LVL 19

Expert Comment

by:Bardobrave
ID: 36968180
You can use a script to loop through your document's DOM and treat each node independently. You can build an output string during the loop and return it after finishing the loop.

You can also use XSLT, but if you are not familiarized with it (and I supose that you aren't as you are asking how to do this) probably it will be better to use the first option, as XSLT learning curve is a bit high.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36968196
I assume you want to do this in XSLT?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs ovid"
    xmlns:ovid="http://ovid.com/rec/elements/1.0/"
    version="1.0">
    
    <xsl:strip-space elements="*"/>
    <xsl:output indent="yes"/>
    
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="ovid:styi">
        <xsl:variable name="stripped-head">
            <xsl:choose>
                <xsl:when test="contains(. , '&lt;ovid:B&gt;')">
                    <xsl:value-of select="substring-after(., '&lt;ovid:B&gt;')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="."/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="stripped-tail">
            <xsl:choose>
                <xsl:when test="contains($stripped-head , '&lt;/ovid:B&gt;')">
                    <xsl:value-of select="substring-before($stripped-head, '&lt;/ovid:B&gt;')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$stripped-head"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="length" select="string-length($stripped-tail)"/>
        <xsl:value-of select="substring($stripped-tail, 1, $length - 2)"/>
        <xsl:value-of select="translate(substring($stripped-tail, $length - 2), '.: ', '')"/>
        <xsl:value-of select="'. '"/>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36968207
mmh, as an XSLT instructor, I don't agree that the learning curve is steep :-)

I would not do this using DOM, since this deals with reconstructing the rest but the ovid:styi...
lot less code in XSLT to deal with this than you would require with DOM
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 19

Expert Comment

by:Bardobrave
ID: 36968244
Of course.

XSLT is the way to do this. But I assume that anyone that know XSLT won't ask how to do this operation. And, although I don't think XSLT is really difficult, I've found that people tends to find it difficult to learn from scratch.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36968277
correct, it doesn't fit procedural thinking, so it as bit of a paradigm shift one has to make.

Anyway, mmalik15 has asked some XSLT questions in the past, so that should be OK
0
 

Author Comment

by:mmalik15
ID: 36968478
Many thanks for the comments guys and sorry I shoud have mentioned i m looking for an xslt solution.

Gertone requirement is slightly different I need to keep the colon if its there at the end of the node e.g.

<styi><ovid:B>Authors' objectives: </ovid:B></styi>
  <styi>To summarise the current scientific knowledge on the causes, diagnosis and treatment of back pain.</styi>
  <styi><ovid:B>Authors' conclusions: </ovid:B></styi>
  <styi>It is important to carefully investigate and document information on patients suffering from back pain to ensure that the problems are not being caused by an injury or organic disease</styi>
  <styi><ovid:B>Index terms: </ovid:B></styi>

the output should be like this

"Authors' objectives: To summarise the current scientific knowledge on the causes, diagnosis and treatment of back pain. Authors' conclusions: It is important to carefully investigate and document information on patients suffering from back pain to ensure that the problems are not being caused by an injury or organic disease."
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 36968923
more like this?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs ovid"
    xmlns:ovid="http://ovid.com/rec/elements/1.0/"
    version="1.0">
    
    <xsl:strip-space elements="*"/>
    <xsl:output indent="yes"/>
    
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="ovid:styi">
        <xsl:variable name="stripped-head">
            <xsl:choose>
                <xsl:when test="contains(. , '&lt;ovid:B&gt;')">
                    <xsl:value-of select="normalize-space(substring-after(., '&lt;ovid:B&gt;'))"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="normalize-space(.)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="stripped-tail">
            <xsl:choose>
                <xsl:when test="contains($stripped-head , '&lt;/ovid:B&gt;')">
                    <xsl:value-of select="normalize-space(substring-before($stripped-head, '&lt;/ovid:B&gt;'))"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="normalize-space($stripped-head)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:value-of select="$stripped-tail"/>
        <xsl:if test="not(contains(':.', substring($stripped-tail, string-length($stripped-tail))))">
                <xsl:text>.</xsl:text>
        </xsl:if>
        <xsl:if test="following-sibling::ovid:styi">
            <xsl:text> </xsl:text>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:mmalik15
ID: 36968972
Excellent buddy
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36969168
welcome
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question