2 Replies Latest reply on Dec 15, 2010 4:58 PM by mcaspers

    Sequencing to sub folders

    mcaspers Newbie

      If I had a repo that looked like the following:

       

      MyXMLDoc.xml

      ASubFolder / MyXMLDoc.xml

       

      (Basically I have two files with the same name stored in the root and ASubFolder folders)

       

      And I sequence this repo using the XmlSequencer, like so:

       

      config.sequencer("Xml")
             .usingClass(XmlSequencer.class)
             .setDescription("XML Sequencer")
             .sequencingFrom("//(*.xml[*])/jcr:content[@jcr:data]")
             .andOutputtingTo("/sequenced/xml/$1");

      config.sequencer("Xml")

           .usingClass(XmlSequencer.class)

           .setDescription("XML Sequencer")

           .sequencingFrom("//(*.xml[*])/jcr:content[@jcr:data]")

           .andOutputtingTo("/sequenced/xml/$1");

       

      I end up with a node called /sequenced/xml/MyXMLDoc.xml that has the sequenced data from both MyXMLDoc.xml files. Is there any way for the sequencer to create /sequenced/xml/MyXMLDoc.xml and /sequenced/xml/ASubFolder/MyXMLDoc.xml nodes?

        • 1. Re: Sequencing to sub folders
          Randall Hauch Master

          Yes, it's actually very easy, though probably not obvious. It all has to do with the capture groups (the parentheses) in the input expression, which are reused in the output expression: '$1' goes with the first parentheses, '$2' goes with the second pair of parentheses, etc. (This works in the same way that capture groups work in regular expressions.) Assuming you keep the output expression the same, you can change the argument to the 'sequencingFrom(...)' method to this:

           

               (//)*.xml[*]/jcr:content[@jcr:data]

           

          if you want the first capture group to include just the path, or to

           

               (//*.xml[*])/jcr:content[@jcr:data]

           

          if you want the first capture group to include the path AND the filename.

           

          BTW, you might want to look at MODE-1013, which affects the XML sequencer. This has been fixed in trunk, and will be included in the next release (2.4).