INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do I return correct event elements

How do I return correct event elements

(OP)
I have a xml 1.0 document with 3 JudgmentEvent.
What I would like to get as output is
1. JudgmentEvent whose parent have not been deleted.
2. JudgmentEvent that have no parent and they have not been deleted.

I do not know how to do this.

My output should look like this:

CODE --> xml

<JudgmentEvent ID="207217600">
	<JudgmentEventType>Judgment - not all parties</JudgmentEventType>
	<Judgment ID="3928438"/>
</JudgmentEvent>
<JudgmentEvent ID="207218513">
	<JudgmentEventType>Adopted</JudgmentEventType>
	<Judgment ID="3928452"/>
</JudgmentEvent> 

The reason I should get

CODE --> xml

<Judgment ID="3928438" InternalID="1613120226"/> 
is because this has amended

CODE --> xml

<Judgment ID="3928436" InternalID="1613120224"/> 
.

xml 1.0 code

CODE --> xml

<?xml version="1.0" encoding="UTF-8"?>
<Case>
	<JudgmentEvent InternalID="1810327075" ID="207217512" Date="05/24/2016">
		<JudgmentEventType InternalID="51314" Word="JDGMULT">Judgment - not all parties</JudgmentEventType>
		<IssueDate>05/24/2016</IssueDate>
		<TimestampCreate>05/24/2016 09:32:50:837</TimestampCreate>
		<TimestampChange>05/24/2016 11:34:15</TimestampChange>
		<Deleted>true</Deleted>
		<AmendReason InternalID="11091" Word="CTORDER">Court Order</AmendReason>
		<Judgment ID="3928437" InternalID="1613120225"/>
		<JudgmentEvent InternalID="1810327074" ID="207217511" Date="05/24/2016">
			<JudgmentEventType InternalID="13024" Word="JUDGGR">Judgment</JudgmentEventType>
			<IssueDate>05/24/2016</IssueDate>
			<AgingClockActionKey Word="SP">Stops case aging clock</AgingClockActionKey>
			<TimestampCreate>05/24/2016 09:32:24:447</TimestampCreate>
			<TimestampChange>05/24/2016 11:51:29</TimestampChange>
			<Deleted>false</Deleted>
			<Judgment ID="3928436" InternalID="1613120224"/>
		</JudgmentEvent>
	</JudgmentEvent>
	<JudgmentEvent InternalID="1810327167" ID="207217600" Date="05/24/2016">
		<JudgmentEventType InternalID="51314" Word="JDGMULT">Judgment - not all parties</JudgmentEventType>
		<IssueDate>05/24/2016</IssueDate>
		<TimestampCreate>05/24/2016 11:51:29:377</TimestampCreate>
		<Deleted>false</Deleted>
		<AmendReason InternalID="11091" Word="CTORDER">Court Order</AmendReason>
		<Judgment ID="3928438" InternalID="1613120226"/>
		<JudgmentEvent InternalID="1810327074" ID="207217511" Date="05/24/2016">
			<JudgmentEventType InternalID="13024" Word="JUDGGR">Judgment</JudgmentEventType>
			<IssueDate>05/24/2016</IssueDate>
			<TimestampCreate>05/24/2016 09:32:24:447</TimestampCreate>
			<TimestampChange>05/24/2016 11:51:29</TimestampChange>
			<Deleted>false</Deleted>
			<RecordingNeeded>false</RecordingNeeded>
			<Judgment ID="3928436" InternalID="1613120224"/>
		</JudgmentEvent>
	</JudgmentEvent>
	<JudgmentEvent InternalID="1810327321" ID="207218513" Date="05/25/2016">
		<JudgmentEventType InternalID="12997" Word="ADOPT">Adopted</JudgmentEventType>
		<IssueDate>05/25/2016</IssueDate>
		<TimestampCreate>05/25/2016 10:35:01:210</TimestampCreate>
		<Deleted>false</Deleted>
		<Judgment ID="3928452" InternalID="1613120240"/>
	</JudgmentEvent>
</Case> 

RE: How do I return correct event elements

Restating:

You wish to select all JudgementEvent nodes where:
  • the parent is a JudgementEvent node which does not contain as a child a Deleted node which has true as its text value; as well as
  • the Parent is not a JudgementEvent node, and no child Deleted node the text value of which is true
I wil make the simplifying assumption, based on your example, that all JudgementEvent nodes have a child node named Deleted.

The Xpath expression for the first item is:

CODE --> Xpath

//JudgementEvent[parent::JudgementEvent][../Deleted != 'true'] 

The XPath expression for the second item is:

CODE --> XPath

//JudgementEvent[local-name(..) != 'JudgementEvent'][Deleted != 'true'] 

The vertical bar ( | ) is the union operator. So to select the union of these two sets:

CODE --> Xpath

//JudgementEvent[parent::JudgementEvent][../Deleted != 'true'] | 
//JudgementEvent[local-name(..) != 'JudgementEvent'][Deleted != 'true'] 

WARNING: Typed, not tested.

XSLT left as an exercise.

Tom Morrison
Hill Country Software

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close