-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing XCOMMONS-2153: index set for siblings but used for nodes. #136
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
--> | ||
<class> | ||
<name>Blog.BlogClass</name> | ||
<customClass/> | ||
<customMapping/> | ||
<defaultViewSheet/> | ||
<defaultEditSheet/> | ||
<defaultWeb/> | ||
<nameField/> | ||
<validationScript/> | ||
<blogType> | ||
<cache>0</cache> | ||
<customDisplay/> | ||
<disabled>0</disabled> | ||
<displayType>select</displayType> | ||
<multiSelect>0</multiSelect> | ||
<name>blogType</name> | ||
<number>5</number> | ||
<picker>0</picker> | ||
<prettyName>Blog type</prettyName> | ||
<relationalStorage>0</relationalStorage> | ||
<separator> </separator> | ||
<separators> ,|</separators> | ||
<size>1</size> | ||
<sort>none</sort> | ||
<tooltip/> | ||
<unmodifiable>0</unmodifiable> | ||
<validationMessage/> | ||
<validationRegExp/> | ||
<values>local=Space blog (aggregates posts from its space only)|global=Global blog (aggregates posts from the entire wiki)</values> | ||
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType> | ||
</blogType> | ||
<description> | ||
<contenttype>FullyRenderedText</contenttype> | ||
<customDisplay/> | ||
<disabled>0</disabled> | ||
<editor>---</editor> | ||
<name>description</name> | ||
<number>2</number> | ||
<picker>0</picker> | ||
<prettyName>Description</prettyName> | ||
<rows>5</rows> | ||
<size>60</size> | ||
<tooltip/> | ||
<unmodifiable>0</unmodifiable> | ||
<validationMessage/> | ||
<validationRegExp/> | ||
<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType> | ||
</description> | ||
<displayType> | ||
<cache>0</cache> | ||
<customDisplay/> | ||
<disabled>0</disabled> | ||
<displayType>select</displayType> | ||
<multiSelect>0</multiSelect> | ||
<name>displayType</name> | ||
<number>3</number> | ||
<picker>0</picker> | ||
<prettyName>Index display</prettyName> | ||
<relationalStorage>0</relationalStorage> | ||
<separator> </separator> | ||
<separators> ,|</separators> | ||
<size>1</size> | ||
<sort>none</sort> | ||
<tooltip/> | ||
<unmodifiable>0</unmodifiable> | ||
<validationMessage/> | ||
<validationRegExp/> | ||
<values>paginated=Paginated|weekly=Group posts weekly|monthly=Group posts monthly|all=Show all posts</values> | ||
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType> | ||
</displayType> | ||
<itemsPerPage> | ||
<customDisplay/> | ||
<disabled>0</disabled> | ||
<name>itemsPerPage</name> | ||
<number>4</number> | ||
<numberType>integer</numberType> | ||
<prettyName>Items per page (only in the Paginated display mode)</prettyName> | ||
<size>2</size> | ||
<tooltip/> | ||
<unmodifiable>0</unmodifiable> | ||
<validationMessage/> | ||
<validationRegExp/> | ||
<classType>com.xpn.xwiki.objects.classes.NumberClass</classType> | ||
</itemsPerPage> | ||
<title> | ||
<customDisplay/> | ||
<disabled>0</disabled> | ||
<name>title</name> | ||
<number>1</number> | ||
<picker>0</picker> | ||
<prettyName>Blog title</prettyName> | ||
<size>30</size> | ||
<tooltip/> | ||
<unmodifiable>0</unmodifiable> | ||
<validationMessage/> | ||
<validationRegExp/> | ||
<classType>com.xpn.xwiki.objects.classes.StringClass</classType> | ||
</title> | ||
</class> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,8 +221,12 @@ private void performTransformations() throws Exception | |
if (parent == null) { | ||
document = xmlDocument; | ||
} else { | ||
// this is the method we use to replace the child and it seems to be | ||
// the canonical way in dom4j (for which a manipulation on a collection | ||
// is a manipulation of the XML tree: We manipulate the elements' list | ||
// by setting the child at the position where it was found. | ||
List<Element> siblings = parent.elements(); | ||
siblings.set(parent.indexOf(node), xmlElement); | ||
siblings.set(siblings.indexOf(node), xmlElement); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add a comment to explain that dom4j There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you Marius. Done in below commit (6bd2104). |
||
} | ||
break; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name the file *.xml since it contains XML.
Also would be good to add a license header (we need to add that to other files too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for the license header.
These files end-up into the XAR... (it could or should be avoided) thus they become pages if they are named
.xml
which would fail since there is noxwikidoc
element. Ok to keep.xwikiclass
?(there's a lot more XML files out there which are not called
.xml
, e.g. the.plist
on macs, or the rss files).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember the test but then it looks like these resource files are placed in the wrong location if they end up in the XAR when they shouldn't. Using a different suffix is not the right way IMO. In XWiki we use xml for xml files (it helps in the IDE, it helps visually know what the file is about, etc). I don't see any valid argument for not doing that honestly, especially since this file is a xwiki XML page which is supposed to end in
.xml
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now checked the code and the doc at https://dev.xwiki.org/xwiki/bin/view/Community/XARPlugin#HTransformations. I think the doc is a bit wrong at https://dev.xwiki.org/xwiki/bin/view/Community/XARPlugin#HTransformations and the files that are used only as intermediary resources that are used for transformations should be excluded. If they're not needed to be processed (velocity doesn't need to run on them) they could also be put in a different directory such as
src/main/xar
. I think that's a better idea than the exclude.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't think exclusion is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. Btw, the file name is entirely left to the developer. If you give the XARMojo a JPEG file as XML source for a REPLACE or INSERT_CHILD, it will (try to) parse it.
So we should open a new bug about the XARMojo so that it implicitly adds excludes for files that are not considered as pages, right? (we could even try to parse the document if xml and exclude it if is not with root
xwikidoc
once we find this method).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the problem and there's no bug to open on XARMojo. It already only reads xml files. The problem is the usage of the XARMojo (ie the tests you're modifying). They must not mix files that are sources for the XAR from files that are sources for the transformations. It's just bad practice and asking for trouble to mix them. It's easy to see that. Imagine if you had named your file .xml, you'd see the issue immediately.
What is the part that you don't understand or don't agree with? I'm asking because we're turning in circles and I feel like I keep repeating myself over and over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.- this discussion should not be here...
2.- I don't agree with the fact that XARMojo should copy vm, html, png, properties or any other file since it does nothing with this
3.- I don't agree with your view that it is best practice to separate the folders between what's the input for the transformation (e.g. properties or vm) and what is not quite the input (e.g. the XML which is, in the absence of transformation, just copied).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so let me redo all the analysis work from scratch (I didn't want to spend so much time on this since it was minor and simple for me):
target/classes
(xwiki-commons/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/XARMojo.java
Line 111 in 348e478
src/main/resources
(except forpackage.xml
but that's potentially an error IMO).src/main/resources
in the existing code and in your PR:Conclusions:
src/main/resources
totarget/classes
while the transformation sources are taken fromsrc/main/resources
which is useless in this case (and prevents using filtering if needed BTW)src/main/resources
totarget/classes
including XML files named*.xml
, which will then be included in the XAR by default (xwiki-commons/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/AbstractXARMojo.java
Line 93 in 71bbc48
Possible solutions:
target/classes
. Note that this works unless we want to use the filtering feature of the maven resources plugin (not the case in this test).src/main/transformations
). This will make sure that the maven resource plugin will not copy them and that the XARMojo won't try to include them in the XAR.pom.xml
of the test to not usesrc/main/resources
for transformation content and instead fetch them fromtarget/classes
(since they've been copied, and they can benefit from filtering too). Configure the XARMojo plugin with includes/excludes to only include what's needed in the generated XAR.Pros/cons:
So I continue to think that solution 2 is the best (@tmortagne seems to think too according to #136 (comment)).
Now you said you don't like it but I don't recall seing any argument from you as to why? Which solution do you prefer and why?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @vmassol ,
I don't like your solution 2 because files that constitute other files should be aside of them. This makes sense, for example, when vm should include neighbour pages... It is disputable and the dispute is really a matter of "conceptual cleanliness vs tools current capabilities". That said, I must say that if you insist that copied files inside a xar are a problem, I guess it is indeed (as @tmortagne mentioned) the lesser evil.
I mentioned my wish for a coherent picture in this more generic post. And I really think we should not argue further on this pull-request as it was just trying to fix a bug in less than two lines while the debate is far broader and touches much older things (e.g. the transformation examples or best practices more than the tests).
paul