winkimjr2 Posted October 9, 2014 Share Posted October 9, 2014 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 More sharing options...
Ingolme Posted October 9, 2014 Share Posted October 9, 2014 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> 1 Link to comment Share on other sites More sharing options...
winkimjr2 Posted October 9, 2014 Author Share Posted October 9, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now