1 Reply Latest reply on Sep 21, 2009 6:39 AM by AdobeScripts

    [VB][CS3] how to re-apply XML Tags in already tagged text ?

    AdobeScripts Level 3

      hi

       

      could anybody tell me what I'm doing wrong and how to do it right ?

       

      I have some text - few paragraphs - styled with same ParaStyle and tagged with same XML tag

       

      1. gfkdjsg f sdk gfkdskf hk dhsk fkds

      2. kfjsdh kf hskd hfk hskd kf dsk

      3. fkhs dkf hksd kf hkds kf kds

      4. k fshd fkj hsdkj fds fks

       

      now user want to change structure and from these 4 paragraphs - make two separate blocks each containing 2-paragraphs with different ParaStyles applied to each block - and each block should be tagged with different XML tag:

       

      1. gfkdjsg f sdk gfkdskf hk dhsk fkds

      2. kfjsdh kf hskd hfk hskd kf dsk

       

      a) fkhs dkf hksd kf hkds kf kds

      b) k fshd fkj hsdkj fds fks

       

      so now user still have one XML block - but two different ParaStyles applied to text - now user need to select some text in block to fix and click in script

       

      I'm doing something like this to select whole XML block when user select for example only part of paragraph 2:

       

      Set myTItem = myInDi.Selection.Item(1).Texts.Item(1).AssociatedXMLElements.Item(1).Texts.Item(1)

       

      now when I try something like this:

       

      Call myTItem.AssociatedXMLElements.Item(1).XMLElements.Add("akapit").Markup(myTItem.Paragraphs .Item(1))

       

      first paragraph of original block of text is tagged - but is moved to the top of XML structure - few levels up ...

       

      what I'm doing wrong ?

       

      thanks in advance

       

      robin

       

      www.adobescripts.co.uk

        • 1. Re: [VB][CS3] how to re-apply XML Tags in already tagged text ?
          AdobeScripts Level 3

          hi again,

           

          Set myTItem = myInDi.Selection.Item(1).Texts.Item(1).AssociatedXMLElements.Item(1).Texts.Item(1)

          Set parentXML = myTItem.AssociatedXMLElements.Item(1).Parent

          For a = myTItem.Paragraphs.Count To 1 Step -1
              Call parentXML.XMLElements.Add("akapit").Markup(myTItem.Paragraphs.Item(a))
          Next a

           

          this works perfect - I have what I need ...

           

          but how to move these new XMLElements one or two levels up and delete/untag original tag ?

          in UserInterface I can select tag in XML structure, and when I select UNTAG - all tags inside this tag remain - go 1 level up

          but when I'm trying to call Untag method for parentXML - all new tags are gone ...

           

          I have this:

           

          <chapter>

            <subchapter>

              <para>

                <text>

                  1. bla bla bla

                  2. bla bla bla

                  3. bla bla bla

                  4. bla bla bla

                </text>

              </para>

            </subchapter>

          </chapter>

           

          and I want to get this:

           

          <chapter>

            <subchapter>

              <para>

                <text>

                  1. bla bla bla

                </text>

              </para>

              <para>

                <text>

                  2. bla bla bla

                </text>

              </para>

              <para>

                <text>

                  3. bla bla bla

                </text>

              </para>

              <para>

                <text>

                  4. bla bla bla

                </text>

              </para>

            </subchapter>

          </chapter>

           

          robin

           

          www.adobescripts.co.uk