[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Processing milestoned XML leads to many preceding:
This is probably not the answer to the question, but looking at the source it seems the <vers> elements are numbered, starting at one at each new <kap> (looked at all 50 kap in http://mcepl.fedorapeople.org/tmp/zdroje/11_Gn.xml). So, wouldn't this work: <xsl:variable name="curPos" select="@n"/> Regards, EB 2012/2/21 MatDj Cepl <mcepl@xxxxxxxxxx>: > Hi, > > I am again working on a XSLT stylesheet to convert a Czech Bible translation > from home-brew schema to OSIS and I got to some performance problems. > > Whole stylesheet is > https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl (and > git repo can be clone from ...), but I believe the relevant parts are > > B B <xsl:template name="genRef"> > B B B B <xsl:variable name="refKniha" select="//kniha[1]/@jmeno"/> > B B B B <xsl:variable name="refKapitola" select="preceding::kap[1]/@n"/> > B B B B <xsl:value-of select="concat($refKniha,'.',$refKapitola,'.')"/> > B B </xsl:template> > > B B <xsl:template name="endVerse"> > B B B B <xsl:param name="rBase" /> > B B B B <xsl:element name="verse"> > B B B B B B <xsl:variable name="prevVerseID"> > B B B B B B B B <xsl:value-of select="./preceding::vers[1]/@n" /> > B B B B B B </xsl:variable> > B B B B B B <xsl:attribute name="eID"> > B B B B B B B B <xsl:value-of select="concat($rBase,$prevVerseID)" /> > B B B B B B </xsl:attribute> > B B B B </xsl:element> > B B </xsl:template> > > B B <!-- ... --> > > B B <xsl:template match="vers"> > B B B B <xsl:variable name="refBase"> > B B B B B B <xsl:call-template name="genRef" /> > B B B B </xsl:variable> > B B B B <xsl:variable name="refID" select="concat($refBase,./@n)" /> > B B B B <!-- Find out whether this is a first verse in a chapter; notice that > <kap/> element is milestoned as well, > B B B B so we have to count a distance in <verse/> elements from it, rather > than use plain count() --> > B B B B <xsl:variable name="curPos" > > select="count(./preceding::kap[1]/following::*[not(count(preceding-sibling::v ers|current()) > = count(preceding-sibling::vers))])" /> > B B B B <xsl:if test="not($curPos=1)"> > B B B B B B <xsl:call-template name="endVerse"> > B B B B B B B B <xsl:with-param name="rBase"> > B B B B B B B B B B <xsl:value-of select="$refBase" /> > B B B B B B B B </xsl:with-param> > B B B B B B </xsl:call-template> > B B B B </xsl:if> > B B B B <xsl:element name="verse"> > B B B B B B <xsl:attribute name="sID"> > B B B B B B B B B B <xsl:value-of select="$refID" /> > B B B B B B B B </xsl:attribute> > B B B B B B <xsl:attribute name="osisID"> > B B B B B B B B B B <xsl:value-of select="$refID" /> > B B B B B B B B </xsl:attribute> > B B B B </xsl:element> > B B </xsl:template> > > This works (at least as much as I was able to test it give then the > circumstances), but the performance is absolutely dreadful. Just book of > Genesis took almost an hour before being processed (with one core of my > dual-core CPU being constantly at 100%). > > Obviously the problem is that <xsl:variable name="curPos"/>, and I read > about how preceding* axes are horribly inefficient all over the Internet, > but unfortunately I haven't figured out any other way how to do what I am > doing and most laments about preceding* axes don't provide much hints > either. > > The problem is (I think) in both <vers/> (that's "verse" in Czech) and > <kap/> (that's an abbreviation of "chapter") are just milestones, so I have > to go through all verses in whole book all the time (yes, this is > http://www.joelonsoftware.com/articles/fog0000000319.html all over again). > > Any ideas? Would some other XSLT processors other than xsltproc (libxml > 20706, libxslt 10126 and libexslt 815) I am using be able to optimize this > somehow? > > Thanks a lot, > > MatDj > > -- > http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz > GPG Finger: 89EF 4BC6 288A BF43 1BAB B 25C3 E09F EF25 D964 84AC > > P2 QQP6P>P9 P<P>P=P0QQQQQ QP> QP2P>P8P< QQQP0P2P>P< P=P5 QP>P4QQ. > B B -- Russian proverb (this time actually checked by a native > B B B Russian)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|