|
Rank: Member
Joined: 5/26/2016 Posts: 19 Location: Maplewood USA
|
I would like to output the first FamilyJudgement from my xml document. How do I do it?
Expected output [code xml]<FamilyJudgment judgmentKey="3928551"> <JudgmentEventTypeText>Custody order</JudgmentEventTypeText> </FamilyJudgment>[/code]
xml document [code xml]<?xml version="1.0" encoding="UTF-8"?> <CaseNotification> <CourtDecisionNotification> <TriggeredDateTime>2016-07-12T15:05:45-05:00</TriggeredDateTime> <NotificationEvent>CourtDecisionModified</NotificationEvent> <FamilyJudgment judgmentKey="3928551"> <JudgmentEventTypeText>Custody order</JudgmentEventTypeText> <JudgmentEventDate>2016-07-12</JudgmentEventDate> <Custody> <CustodyDescriptionText>Legal custody</CustodyDescriptionText> </Custody> </FamilyJudgment> <FamilyJudgment judgmentKey="3928551"> <JudgmentEventTypeText>Custody order</JudgmentEventTypeText> <JudgmentEventDate>2016-07-12</JudgmentEventDate> <Custody> <CustodyDescriptionText>Legal custody</CustodyDescriptionText> </Custody> </FamilyJudgment> </CourtDecisionNotification> </CaseNotification>[/code]
|
|
Rank: Newbie
Joined: 10/28/2002 Posts: 1,283 Location: AT
|
If you want the whole of the first "FamilyJudgement" element:
Code:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/CaseNotification/CourtDecisionNotification"> <xsl:copy-of select="FamilyJudgment[1]"/> </xsl:template> </xsl:stylesheet>
If you want the first "FamilyJudgement" element and only the "JudgementType" child element:
Code:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/CaseNotification/CourtDecisionNotification"> <xsl:apply-templates select="FamilyJudgment[1]"/> </xsl:template> <xsl:template match="FamilyJudgment"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:copy-of select="JudgmentEventTypeText"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
|
|
Rank: Member
Joined: 5/26/2016 Posts: 19 Location: Maplewood USA
|
Thanks for your help
|
|
guest |