Giles Hunt
Giles Hunt

Reputation: 531

Trim a string in XSLT after a character

I have an xslt for this data feed. I need to be able to remove all characters in landingPage that occur after the ?. Can someone please help get me started?

Thanks

<StyleAPI>
<styles>
    <style>
        <brand>Nike</brand>
        <categoryId>9</categoryId>
        <categoryName>Apparel</categoryName>
        <defaultImage>http://myntra.myntassets.com/images/style/properties/Nike-Sahara-Team-India-Fanwear-Round-Neck-Jersey_2d27392cc7d7730e8fee0755fd41d30c_images_mini.jpg</defaultImage>
        <description>Blue round neck Sahara Team India jersey, has short sleeves, print on the chest and back chest. Warranty for manufacturing defects: 6 months (not valid on products with more than 20% discount).</description>
        <gender>Men</gender>
        <inventoryStatus>0</inventoryStatus>
        <landingPage>http://www.myntra.com/tshirts/nike/nike-sahara-team-india-fanwear-round-neck-jersey/1163/buy?utm_source=aff-omg&amp;utm_medium=cpa&amp;utm_campaign=data-feed1163</landingPage>
        <price>895.0</price>
        <productDisplayName>Nike Sahara Team India Fanwear Round Neck Jersey</productDisplayName>
        <searchImage>http://myntra.myntassets.com/images/style/style_search_image/Nike-Sahara-Team-India-Fanwear-Round-Neck-Jersey_2d27392cc7d7730e8fee0755fd41d30c_images_180_240.jpg</searchImage>
        <sizesNotAvailable>XXS,XS,S,M,L,XL,XXL,XXXL</sizesNotAvailable>
        <styleId>1163</styleId>
        <subCategoryId>31</subCategoryId>
        <subCategoryName>Topwear</subCategoryName>
        <subSubCategoryId>90</subSubCategoryId>
        <subSubCategoryName>Tshirts</subSubCategoryName>
    </style>

Upvotes: 2

Views: 904

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167591

Use substring-before(landingPage, '?') to get e.g. http://www.myntra.com/tshirts/nike/nike-sahara-team-india-fanwear-round-neck-jersey/1163/buy. If you want to keep the question mark at the end then you could use concat(substring-before(landingPage, '?'), '?').

Upvotes: 3

Related Questions