Click here to Skip to main content
15,917,320 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to get the following output from xml document but I am not sure how to do it. Can someone help please?

Desired output
XML
<?xml version="1.0" encoding="UTF-8"?>
<Integration>
   <ProtectionOrderStatus>
        <ProtectionOrderStatusCode>DELETED</ext:ProtectionOrderStatusCode>
    </ProtectionOrderStatus>
</Integration>


In put document
XML
<?xml version="1.0" encoding="UTF-8"?>
<Integration>
	<ProtectionOrder>
		<Deleted>true</Deleted>
		<ProtectionOrderNumber>12</ProtectionOrderNumber>
		<Statuses>
			<Status>
				<Current>true</Current>
				<Active>Yes</Active>
				<Date>03/16/2017</Date>
				<Type Word="SBJO">Signed By Judicial Officer</Type>
			</Status>
		</Statuses>
	</ProtectionOrder>
</Integration>


What I have tried:

I am not sure how to go about it.
Posted
Updated 21-Mar-17 2:35am
Comments
[no name] 16-Mar-17 12:25pm    
Why would you want invalid XML as an output? That makes no sense.
Richard Deeming 16-Mar-17 13:52pm    
Apart from the fact that your desired output is not valid XML, you haven't told us which language you're using to transform the XML file, or shown us what you've tried.
Graeme_Grant 16-Mar-17 22:36pm    
Ignoring the typo(?), are you wanting to Transform the XML from one format to another?

I did figure this out. This is what I did in existing xslt. I realized I forgot to add the xslt code. My apologies.
XML
<ext:ProtectionOrderStatus>
	<xsl:choose>
		<xsl:when test="Deleted='true'">
			<ext:ProtectionOrderStatusCode>
				<xsl:text>DELETED</xsl:text>
			</ext:ProtectionOrderStatusCode>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$vStatusWord"/>
		</xsl:otherwise>
	</xsl:choose>
</ext:ProtectionOrderStatus>
 
Share this answer
 
I found a solution. This is because I want to display the word DELETED in the select statement for the value.
XML
<ext:ProtectionOrderStatus>
	<xsl:choose>
		<xsl:when test="Deleted='true'">
			<ext:ProtectionOrderStatusCode>
				<xsl:value-of select ="name(Deleted)"/>
			</ext:ProtectionOrderStatusCode>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$vStatusWord"/>
		</xsl:otherwise>
	</xsl:choose>
</ext:ProtectionOrderStatus>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900