1

I would like to know how to delete a part of string from string when converting from one XML to another XML.

For example, say I have the source XML that has:

<element id="#yo">

however, after the translation I want this to be

<element id="yo">

Can I do this easily in XSLT? let me know thanks

also, can I do vice versa? yo to #yo

1 Answer 1

1
<xsl:template match="element[starts-with(@id,'#')]">
<element id="{substring(@id,2)}">
  <xsl:apply-templates/>
</element>
</xsl:template>

and in reverse

<xsl:template match="element">
<element id="#{@id}">
  <xsl:apply-templates/>
</element>
</xsl:template>
Sign up to request clarification or add additional context in comments.

1 Comment

I have just realised that I can use concat and substring. Anyway thank you very much for your response!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.