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

Re: Processing two documents, which order?

Subject: Re: Processing two documents, which order?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 08 Apr 2011 14:14:33 +0100
Re:  Processing two documents
On 08/04/2011 11:00, Dave Pawson wrote:
15 minutes run time is good with that sort of comparison!

Michael Kay and Tony Nassar have already suggested just tokenizing the words with a fixed regex (which may be compiled) and using a key to check which words you want to markup (which should be fast).


How long does this take on your real data?


doc1 <x> <word>one</word> <word>two</word> <word>three</word> <word>threesome</word> <word>x-ray</word> </x>

doc2
<body>
<p id="a">one hmmm not-one  zzzzz three</p>
<p id="b">a two one tone three</p>
<p>zzz hhh aaa iii aaa x-ray hhh</p>
</body>


dp.xsl


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="w" match="word" use="."/>

<xsl:template match="node()">
 <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

<xsl:template match="text()" priority="2">
 <xsl:analyze-string select="." regex="[A-Za-z][a-z---]+">
  <xsl:matching-substring>
   <xsl:choose>
    <xsl:when test="key('w',.,doc('doc1.xml'))">
     <property>
      <xsl:value-of select="."/>
     </property>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="."/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:matching-substring>
  <xsl:non-matching-substring>
   <xsl:value-of select="."/>
  </xsl:non-matching-substring>
 </xsl:analyze-string>
</xsl:template>

</xsl:stylesheet>


saxon9 doc2.xml dp.xsl
<?xml version="1.0" encoding="UTF-8"?><body>
<p id="a"><property>one</property> hmmm not-one zzzzz <property>three</property></p>
<p id="b">a <property>two</property> <property>one</property> tone <property>three</property></p>
<p>zzz hhh aaa iii aaa <property>x-ray</property> hhh</p>
</body>


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


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.