IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

How do I get the first FamilyJudgement from xml doc? Options · View
winkimjr2
Posted: Monday, July 25, 2016 9:41:25 PM
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]
island
Posted: Tuesday, July 26, 2016 8:09:15 AM
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>

winkimjr2
Posted: Wednesday, July 27, 2016 2:41:18 PM
Rank: Member

Joined: 5/26/2016
Posts: 19
Location: Maplewood USA
Thanks for your help
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.