Jump to content

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


winkimjr2

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?
Link to comment
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
Link to comment
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>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...