1 Reply Latest reply on Jan 2, 2013 9:32 PM by SLTyPete

    Script XMLrule or ??? to group elements under new parent?

    SLTyPete Level 1

      Back after a few weeks on a non-Adobe urgent project plus some recovery ...

       

      I'm wondering if anyone has XML / XMLrule scripting experience sufficient to give me at least a hint on the following challenge. I have discovered the online scripting tutorials, documents and sample files (huge collection!)... unfortunately I can't find even the beginnings of something addressing what looks to me like a common and highly scriptable challenge.

       

      My example is below. I can't find code snippets for any of the following:

         - traversing a set of elements to find and select a set of desired elements

         - inserting a selected set (range?) of elements into a new parent

       

      This is pretty clear when done manually in the user interface, but opaque in the scripting / XMLrules environment.

       

      Anybody got any hints? Or a book / resource that digs in deep enough?

       

      Thanks much,

      Pete

      ----------------------

       

      Example of the problem:

       

      Imagine at some level of a tag structure you have ANY kind of repeating tag sequence. E.g. (in highly abbreviated form)

       

      <people>

         <name>

         <address>

         <phone>

         <name>

         <address>

         <phone>

         <name>

         <address>

         <phone>

      <projects>

          <name>

          <startdate>

          <enddate>

          <name>

          <startdate>

          <enddate>

       

      What I want is to group sets of elements underneath a new parent, something like

       

      (virtually)... GatherElementsUnder(XPath,StartWithElement,NewParentElement)

      ie

      GatherElementsUnder(/people,name,person)

      GatherElementsUnder(/projects,name,project)

      would produce

       

       

      <people>

        <person>

           <name>

           <address>

           <phone>

        <person>

           <name>

           <address>

           <phone>

        <person>

           <name>

           <address>

           <phone>

      <projects>

        <project>

            <name>

            <startdate>

            <enddate>

        <project>

            <name>

            <startdate>

            <enddate>