From mbriskar at redhat.com  Thu Jan 28 11:21:17 2016
From: mbriskar at redhat.com (Matej Briskar)
Date: Thu, 28 Jan 2016 11:21:17 -0500 (EST)
Subject: [windup-dev] XmlFile unexpected results?
In-Reply-To: <89928846.13174153.1453997273202.JavaMail.zimbra@redhat.com>
Message-ID: <1456206976.13186416.1453998077544.JavaMail.zimbra@redhat.com>

A topic from today's meeting, however I thought it will be better understood in text.
XmlFile may cause confusion, because it may return different results based on what it is queried for and therefore throw exceptions in some cases.
1. XmlFile querying for xpath will always return part of the file with the line number etc.
2. XmlFile not querying for xpath but other things (used DTD query or something similar), returns the whole file.

The problem here is that using second XmlFile-style without xpath throws exception when used with Hints. Therefore the second condition supports only classifications. 
Is this expected behaviour? That is the my only question.

E.g
This works:
<when>
  <xmlfile matches="*xpath*" />
<perfom>
  <hint>
   ...
  </hint>
</perform>

This does not and throws exception (cannot cast to FileLocationModel):
<when>
  <xmlfile public-id="*xpath*" />
<perfom>
  <hint>
   ...
  </hint>
</perform>

If that is not a problem, it is OK. Just wanted to point it out.

From jsightle at redhat.com  Fri Jan 29 16:02:17 2016
From: jsightle at redhat.com (Jess Sightler)
Date: Fri, 29 Jan 2016 16:02:17 -0500
Subject: [windup-dev] XmlFile unexpected results?
In-Reply-To: <1456206976.13186416.1453998077544.JavaMail.zimbra@redhat.com>
References: <1456206976.13186416.1453998077544.JavaMail.zimbra@redhat.com>
Message-ID: <56ABD359.9000104@redhat.com>

File.java used to have this problem as well:

https://github.com/windup/windup/blob/master/rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/File.java

Because of this, we changed it a while back so that it actually returns 
a filelocationmodel pointing to the first part of the file. I think that 
works pretty well.

On 01/28/2016 11:21 AM, Matej Briskar wrote:
> A topic from today's meeting, however I thought it will be better understood in text.
> XmlFile may cause confusion, because it may return different results based on what it is queried for and therefore throw exceptions in some cases.
> 1. XmlFile querying for xpath will always return part of the file with the line number etc.
> 2. XmlFile not querying for xpath but other things (used DTD query or something similar), returns the whole file.
>
> The problem here is that using second XmlFile-style without xpath throws exception when used with Hints. Therefore the second condition supports only classifications.
> Is this expected behaviour? That is the my only question.
>
> E.g
> This works:
> <when>
>    <xmlfile matches="*xpath*" />
> <perfom>
>    <hint>
>     ...
>    </hint>
> </perform>
>
> This does not and throws exception (cannot cast to FileLocationModel):
> <when>
>    <xmlfile public-id="*xpath*" />
> <perfom>
>    <hint>
>     ...
>    </hint>
> </perform>
>
> If that is not a problem, it is OK. Just wanted to point it out.
> _______________________________________________
> windup-dev mailing list
> windup-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/windup-dev