Altova Mailing List Archives


Re: [xsl] How to fetch desired data

From: rob Jackson <robjackson2002@--------->
To:
Date: 12/31/2005 7:44:00 AM
Hi Florent,

Thanks for the solution but still there is some problem.
If you see my source xml which is like

<xsl:address>Charles Army Street; Boston, Ma 01779</xsl:address>

which has got space after comma and before 'Ma'. So it is
displaying the result as
<state></state>
<zip>Ma 01779</zip>

I have modified your code to get the desired result.

   <xsl:variable name="before"
                 select="substring-before($vAddress, ',')"/>
   <xsl:variable name="after"
                 select="substring-after($vAddress, ',')"/>
   <xsl:variable name="tmp"
                 select="substring-after($after, ' ')"/>
   <xsl:variable name="state"
                 select="substring-before($tmp, ' ')"/>
   <xsl:variable name="zip"
                 select="substring-after($tmp, ' ')"/>


-Rob


   <MyCity><xsl:value-of select="$before"/></MyCity>
   <MyState><xsl:value-of select="$state"/></MyState>
   <MyZip><xsl:value-of select="$zip"/></MyZip>


On 12/30/05, Florent Georges <darkman_spam@xxxxxxxx> wrote:
> rob Jackson wrote:
>
> > By using substring-before comma I am able to get
> > <city>Charles Army Street; Boston</city>
>
> > but substring-after comma gives me 'Ma 01779'
>
> > I want this also to be split as
> > <state>Ma</state>
> > <zip>01779</zip>
>
>    <xsl:variable name="before"
>                  select="substring-before(..., ',')"/>
>    <xsl:variable name="after"
>                  select="substring-after(..., ',')"/>
>    <xsl:variable name="state"
>                  select="substring-before($after, ' ')"/>
>    <xsl:variable name="zip"
>                  select="substring-after($after, ' ')"/>
>
>    <...><xsl:value-of select="$before"/></...>
>    <state><xsl:value-of select="$state"/></state>
>    <zip><xsl:value-of select="$zip"/></zip>
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ___________________________________________________________________________
> Nouveau : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs
exceptionnels pour appeler la France et l'international.
> Tilichargez sur http://fr.messenger.yahoo.com

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.