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

Re: FW: tokenize

Subject: Re: FW: tokenize
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Oct 2016 14:20:30 -0000
Re:  FW: tokenize
Hello JSR,

The anomalies you are seeing in your results are undoubtedly related
to irregularities in the input data. (In this case, probably the ", "
substring you are looking for only sometimes appears in its own 'w:r'
element wrapper.)

I imagine if you look closely enough at the data you will be able to
see this ... although (this is evidently WordML) then again maybe not.
The input -- both the format itself, and the way the upstream
application (presumably MS Word) handles the tagging -- is a mess.

This is why Michael also suggested you run two passes, the first to
clean up your data, the second to perform your mapping into your
target tag set.

This gives you a better chance to discover such irregularities in your
input and deal with them, or work around them.

Good luck,
Wendell


On Fri, Oct 14, 2016 at 12:06 AM, Joga Singh Rawat
jrawat@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi Michael,
>
> Your suggestion worked partially.  Now we are getting below output.
>
> <aug>
>       <au>Amanda Ganem,M.D.<sup>1,&amp;x00B6;,*</sup>, </au>
>       <au>Elias P. Bonaros,M.D.<sup>2</sup>, Bibiana D.
Stephen<sup>3</sup>,
> </au>
>       <au>J.H. Calderon Jr<sup>2</sup>, J.H. Calderon<sup>5,6</sup>, </au>
>       <au>W. WYAT Hoback<sup>4,6</sup>
>       </au>
> </aug>
>
> By applying
>
> <xsl:for-each-group select="w:r" group-ending-with="*[.=', ']">
>       <au>
>        <xsl:apply-templates select="current-group()"/>
>       </au>
> </xsl:for-each-group>
>
> Please, notice the position of the comma (,). <w:r><w:t>, </w:t></w:r> is
> working fine but   <w:r><w:t>, Bibiana D</w:t></w:r> is not getting grouped
> properly.
>
> Thanks
> ...JSR
>
> -----Original Message-----
> From: Joga Singh Rawat [mailto:jrawat@xxxxxxxxxxxxxx]
> Sent: 12 October 2016 14:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: tokenize
>
> Hi Experts,
>
> I am not getting the Expected Output by following inputs. Any idea? Thanks
> in advance.
>
> Input
> <w:p>
>   <w:pPr><w:pStyle w:val="Authors0"/></w:pPr>
>   <w:r><w:t>Amanda
> </w:t></w:r><w:r><w:t>Ganem</w:t></w:r><w:r><w:t>,M.D.</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign
> w:val="superscript"/></w:rPr><w:t>1,CB6,*</w:t></w:r>
>   <w:r><w:t>, </w:t></w:r>
>   <w:r><w:t>Elias P. Bonaros,M.D.</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:t>2</w:t></w:r>
>   <w:r><w:t>, Bibiana D</w:t></w:r>
>   <w:r><w:t>. Stephen</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:t>3</w:t></w:r>
>   <w:r><w:t>, </w:t></w:r>
>   <w:r><w:t>J.H. Calderon Jr</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:t>2</w:t></w:r>
>   <w:r><w:t>, J.H. Calderon</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign
w:val="superscript"/></w:rPr><w:t>5,6</w:t></w:r>
>   <w:r><w:t xml:space="preserve">, </w:t></w:r>
>   <w:r><w:t>W. WYAT Hoback</w:t></w:r>
>   <w:r><w:rPr><w:vertAlign
w:val="superscript"/></w:rPr><w:t>4,6</w:t></w:r>
> </w:p>
>
> Xslt
> <xsl:template match="w:p">
>    <xsl:if test="w:pPr/w:pStyle/@w:val='Authors0'">
>     <aug>
>      <xsl:apply-templates select="*" mode="make-tokens"/>
>    </aug>
> </xsl:if>
> </xsl:template>
> <xsl:template match="*" mode="make-tokens">
>   <xsl:for-each select="tokenize(.,', ')">
>    <xsl:if test=".!=''">
>     <au><xsl:copy-of select="."/></au>
>    </xsl:if>
>   </xsl:for-each>
>  </xsl:template>
>  <xsl:template match="w:r[w:rPr/w:vertAlign/@w:val='superscript']"
> mode="make-tokens">
>   </xsl:variable>
>   <sup><xsl:value-of select="."/></sup>
>  </xsl:template>
>
> Current output
>    <aug>
>       <au>Amanda </au>
>       <au>Ganem</au>
>       <au>,M.D.</au>
>       <sup>1,&amp;x00B6;,*</sup>
>       <au>Elias P. Bonaros,M.D.</au>
>       <sup>2</sup>
>       <au>Bibiana D</au>
>       <au>. Stephen</au>
>       <sup>3</sup>
>       <au>J.H. Calderon Jr</au>
>       <sup>2</sup>
>       <au>J.H. Calderon</au>
>       <sup>5,6</sup>
>       <au>W. WYAT Hoback</au>
>       <sup>4,6</sup>
>    </aug>
>
> Expected output
>    <aug>
>       <au>Amanda Ganem,M.D. <sup>1,&amp;x00B6;,*</sup></au>
>       <au>Elias P. Bonaros,M.D.<sup>2</sup></au>
>       <au>Bibiana D. Stephen<sup>3</sup></au>
>       <au>J.H. Calderon Jr<sup>2</sup></au>
>       <au>J.H. Calderon<sup>5,6</sup></au>
>       <au>W. WYAT Hoback<sup>4,6</sup></au>
>    </aug>
>



--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^

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.