Remove value from string in XSLt - Version 1

I have an XML document with the following syntax as an example:

        <ROOM> Room Name 1</ROOM>

What I want to do is select the string ROOM but only return "Name 1" and remove the word "room" from the string.

How can this be done in XSL 1?



One possible XSL 1.0 transormation, assuming that the target substring "Room" is always either at the beginning or not exists :

<xsl:stylesheet version="1.0" xmlns:xsl="">
<!-- identity template : copy element, unchanged -->
<xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>

<!-- custom template to copy ROOM element and remove substring 'Room' from the inner text -->
<xsl:template match="ROOM[contains(.,'Room')]">
        <xsl:value-of select="normalize-space(substring-after(., 'Room'))"/>

xsltranform demo

This can be done by using the following template:

     <xsl:template name="string-replace-all">
    <xsl:param name="text" />
    <xsl:param name="replace" />
    <xsl:param name="by" />
      <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text,$replace)" />
        <xsl:value-of select="$by" />
        <xsl:call-template name="string-replace-all">
          <xsl:with-param name="text"
          select="substring-after($text,$replace)" />
          <xsl:with-param name="replace" select="$replace" />
          <xsl:with-param name="by" select="$by" />
        <xsl:value-of select="$text" />

In place of the normal select value of, use:

 <xsl:variable name="myVar">
                                            <xsl:call-template name="string-replace-all">
                                              <xsl:with-param name="text" select="ROOM" />
                                              <xsl:with-param name="replace" select="'Room'" />
                                              <xsl:with-param name="by" select="''" />

                                          <xsl:value-of select="$myVar" />

Need Your Help

How to load JSON using ObjectMapper to map to a specific class structure?

java json jackson

Can I use Jackson ObjectMapper to load data from a JSON file directly into my own data structure? I'm trying to load a map of objects from a JSON file, but not sure how to do it.

Add network service

service wix install driver

I have a kernel service driver , i want to install it with an installer .