Jump to content
Sign in to follow this  
winkimjr2

How do I override a xml value in xslt with a different value?

Recommended Posts

In short whenever my xml element has the following DC19DAKHN or DC19D0000 , in xslt output I want to override that value with MN019015J .
How do I do this in XSLT?
My XML Code
<ValueID><MyID>DC19DAKHN</MyID></ValueID>
My xslt output is
<myID>DC19D0000</myID>
I want this to look like this instead
<myID>MN019015J</myID>
Do I use If Choose?

Share this post


Link to post
Share on other sites

It's been a while since I last worked with XSL but this is probably similar to what you want:

<xsl:choose>    <xsl:when test="MyID='DC19DAKHN'">        <MyID>MN019015J</MyID>    </xsl:when>    <xsl:when test="MyID='DC19D0000'">        <MyID>MN019015J</MyID>    </xsl:when>    <xsl:otherwise>        <MyID><xsl:value-of select="MyID"/></MyID>    </xsl:otherwise></xsl:choose>
  • Like 1

Share this post


Link to post
Share on other sites

It's been a while since I last worked with XSL but this is probably similar to what you want:

<xsl:choose>    <xsl:when test="MyID='DC19DAKHN'">        <MyID>MN019015J</MyID>    </xsl:when>    <xsl:when test="MyID='DC19D0000'">        <MyID>MN019015J</MyID>    </xsl:when>    <xsl:otherwise>        <MyID><xsl:value-of select="MyID"/></MyID>    </xsl:otherwise></xsl:choose>

 

I think you need more information to be able to help me. When the enforcement agency ID is DC19D0000 this will be changed to MN019015J. However, the last 4 digits will be stripped and instead add 4 0s, so the output will show MN0190000.Here is my template xsl code<!--Template to produce service--><EnforcementAgency><OrganizationIdentification><nc:IdentificationID><xsl:choose><xsl:when test="/Integration/Case/Court[CourtNCIC=DC19D0000]"><xsl:text>MN019015J</xsl:text></xsl:when><xsl:otherwise><xsl:value-of select="substring(//Integration/Case/Court/CourtNCIC,1,5)"/><xsl:text>0000</xsl:text></xsl:otherwise></xsl:choose></nc:IdentificationID></OrganizationIdentification></EnforcementAgency>Here is my XML document<Court><NodeID>13045</NodeID><CourtNCIC>DC19DAKHN</CourtNCIC></Court>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...