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

Help with regex

Subject: Help with regex
From: "Ginny Wagner" <ginnywagner@xxxxxxxxxxxxxx>
Date: Sat, 2 Apr 2011 14:52:00 -0500
 Help with regex
The following is a system that will relate various names(citations) from
various sources to a specific person. I need to bring the sourceref and the
personref into equal strings with the matching ids in their xml pages. I
have over 90,000 name records that need to be translated properly so that
the refid will match the id in the other xml docs. 

name.xml
<names>
<citation>
<name id="N000002"/>
<forename>Bob</forename>
<descriptor>Jones</descriptor>
<sourceref refid="S3568"/>
<source>ww</source>
<edition>1995</edition>
<reference>p. 254</reference>
<personref refid="P875"/>
<knownby>Robert Jones</knownby>
</citation>
<citation>
<name id="N000005"/>
<forename>Stretch</forename>
<descriptor>Jones</descriptor>
<sourceref refid="S10312"/>
<source>ww</source>
<edition>1998</edition>
<reference>p. 189</reference>
<personref refid="P875"/>
<knownby>Robert Jones</knownby>
</citation>
</<names>

person.xml
<person id="P000875" security="private" knownby="Robert Jones" gender="male"
status="Artist" provenance="England" existence="deceased" family="yes"
county="York" pnotes="He created over one thousand paintings most of which
now hang in museums across the United States and Canada. His son, Robert
Jones, Jr. built the Jones Museum in London which houses over one hundred of
his paintings as well as fifty paintings of his wife, Celia Jones. His style
is cubist. He studied with Picasso when just a young boy."/>  

source.xml
<source source-id="S003568" type="Who's Who" edition="1995" reference="page
94" county="London">Blah Blah Blah <name>Bob Jones</name> blah blah artist
of the year in Brussels.
<notes></notes></source>
<source source-id="S010312" type="Who's Who" edition="1998" reference="page
98" county="London">Blah Blah Blah <name>Stretch Jones</name> blah blah
artist of the year in Paris.
<notes>Toured the United States in 1997.</notes></source>

The psuedo code I have is come up with is:

Left 1 = var Y:  var Y=P or S
Find resultant length and store in var X: 875, 3568, 10312, (3, 4, 5)
6- var X = var Z : 3, 2, 1
Var Z = no. of 0 to append to var Y : P000, S00, S0
Concatenate var Y and var Z:  P000875, S003568, S010312

The result should be:

name.xml
<names>
<citation>
<name id="N000002"/>
<forename>Bob</forename>
<descriptor>Jones</descriptor>
<sourceref refid="S003568"/>
<source>ww</source>
<edition>1995</edition>
<reference>p. 254</reference>
<personref refid="P000875"/>
<knownby>Robert Jones</knownby>
</citation>
<citation>
<name id="N000005"/>
<forename>Stretch</forename>
<descriptor>Jones</descriptor>
<sourceref refid="S010312"/>
<source>ww</source>
<edition>1998</edition>
<reference>p. 189</reference>
<personref refid="P000875"/>
<knownby>Robert Jones</knownby>
</citation>
</<names>

My (nonworking) xsl translation is:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
 <xsl:template match="/"> 
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

    
   <xsl:function name="str:characters" as="xs:string*">
        <xsl:param name="string" as="xs:string" />
        <xsl:if test ="$string">
  <xsl:sequence select="substring($string, 1, 1)" as="uppercase" />
            <xsl:variable name="remainder" select="substring($string, 2)"
as="string" />
            <xsl:if test="remainder">
                <xsl:sequence select="str:characters($remainder)" />
    <xsl:count($remainder()*) as integer/>
 <xsl:sum(6-($remainder) as="xs:addon" />
                <xsl:string xsl:string-join((xs:$uppercase, $addon,
$remainder)) />
            </xsl:if>
        </xsl:if>
   </xsl:function>
 </xsl:template> 
</xsl:stylesheet>

I get an error on the count statement in oXygen and I can't seem to get any
further. Any help would be greatly appreciated! 

Ginny Wagner

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.