Skip to content

AttributeFilter with nodematcher #259

@aceankit99

Description

@aceankit99

Hi Stefan,

I want to find out the difference between 2 xml file, ignoring few attribute of a node.

my XML-</AssignedContent> <AssignedContent ContentClass="FKN" IsRequired="false"> <ContentAttributes> <ContentAttribute AttributeName="PARAMETER-ABHAENGIGKEITe" CommentRequired="N" Description="Parameterabhängigkeit der Funktion" Group="FKN" LockedForGUI="R" MultipleValues="false" OnlyNormValues="false" Required="false" ShowNulls="true"> <ContentGrants/> </ContentAttribute> </ContentAttributes> </AssignedContent>

code which i tried-

` Diff diffs = DiffBuilder.compare(Source).withTest(Source2).ignoreComments().ignoreWhitespace()
.ignoreElementContentWhitespace().checkForSimilar()
.withNodeMatcher(new DefaultNodeMatcher(
ElementSelectors.conditionalBuilder().whenElementIsNamed("ContentAttributes")
.thenUse(ElementSelectors.byXPath("./ContentAttribute/text()",
ElementSelectors.byNameAndAttributes("Description")))
.elseUse(ElementSelectors.byNameAndAllAttributes).build()))
.withAttributeFilter(attr -> (attr.getName().equals("AttributeName"))

	    .withAttributeFilter(attr -> attr.getName().equals("AttributeName"))
	    .build();`

I tried with both withAttributeFilter and withDifferenceEvaluator but its not working. I wanted to ignore the AttributeName attribute of ContentAttribute .

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions