5 Replies Latest reply on May 24, 2011 1:34 PM by kmc27

    Use InDesign GREP to Identify and Modify XML Tagged Text?

    kmc27 Level 1

      I am using InDesign CS4 for the Mac. My InDesign documents are built by importing XML files. I am modifying one of my Paragraph Styles by adding a Grep Style to it. I'd like the GREP Style to identify any text (any character) that is found between the XML tags of "saleprice" and a apply a Character Style to that text.

       

      I saw the following information under the XML Character Classes section on the InDesign GREP Help page: "\i, \I, \c and \C shorthand XML name character classes"

       

      Does this mean it is possible to set up a GREP style that identifies any text that is tagged with a specific XML name? If so, can someone explain how this would work - none of my GREP styles have worked so far.

       

      Thanks in advance for any help on this.

        • 1. Re: Use InDesign GREP to Identify and Modify XML Tagged Text?
          John Hawkinson Level 5

          TLDR: No.

          More details:

          I saw the following information under the XML Character Classes section on the InDesign GREP Help page: "\i, \I, \c and \C shorthand XML name character classes"

           


          Oh, this is Jongware's page: http://www.jongware.com/idgrephelp.html.

           

          Does this mean it is possible to set up a GREP style that identifies any text that is tagged with a specific XML name? If so, can someone explain how this would work - none of my GREP styles have worked so far.

          No, it doens't mean that. That table is a survey of whether InDesign's GREP implementation supports regular expression features, and adjacent to that feature it says "No."

           

          Furthermore, I don't believe that feature would do what you think it does. See http://www.regular-expressions.info/xmlcharclass.html. They allow you to match characters that are valid in tags, but not a specific tag.

           

          For InDesign regexp reference, I would stick with Metacharacters for searching.

           

          In the future, if you're citing a non-Adobe reference, it's probably good to be more clear about that. At first I thought you were discussing Adobe's web page on the topic and got fairly confused.

          • 2. Re: Use InDesign GREP to Identify and Modify XML Tagged Text?
            [Jongware] Most Valuable Participant

            John Hawkinson wrote:

             

            I saw the following information under the XML Character Classes section on the InDesign GREP Help page: "\i, \I, \c and \C shorthand XML name character classes"

             

            Oh, this is Jongware's page: http://www.jongware.com/idgrephelp.html.

             

            Well that explains why these codes didn't ring any bells for me!

             

            If the OP had read a bit more carefully (indeed, as you say, paying attention to what "official" help pages are and what not), he'd also have seen:

             

            (a) "There are a few question marks, because I'm not really sure how these functions should to work "

            (b)

            FeatureCS4
            \i, \I, \c and \C shorthand XML name character classes?

             

            (And I take it I can safely change the ? to a No.)

            • 3. Re: Use InDesign GREP to Identify and Modify XML Tagged Text?
              [Jongware] Most Valuable Participant

              Apart from various other mistakes (see the other posts ), this one is the most important:

               

              GREP inside InDesign only works on plain text inside InDesign.

               

              That means you cannot search for 'xml tag names' with GREP, just like you cannot search for a paragraph style name ("Heading \d") or a swatch name ("\[Paper\]"). GREP also cannot find the individual digits in an automatic page number code, or any text inside variables.

               

              You are thinking way out of the box. It seems all you want to do is apply special formatting to an XML element called "saleprice". Why not use the regular functions for that?

              • 4. Re: Use InDesign GREP to Identify and Modify XML Tagged Text?
                John Hawkinson Level 5

                Oh, this is Jongware's page: http://www.jongware.com/idgrephelp.html.

                 

                Well that explains why these codes didn't ring any bells for me!

                Aren't we the funny one!

                 

                Of course, if I had read a little more carefully, I'd have noted it was "??" and not "No" like I said it was:

                 

                and adjacent to that feature it says "No."

                But anyhow, like it says at http://www.regular-expressions.info/xmlcharclass.html,


                "XML Schema Regular Expressions support the usual six shorthand character classes, plus four more. These four aren't supported by any other regular expression flavor."

                (emphasis mine)

                (And I take it I can safely change the ? to a No.)

                Quite!

                • 5. Re: Use InDesign GREP to Identify and Modify XML Tagged Text?
                  kmc27 Level 1

                  Thanks John and Jongware

                   

                  Jongware, you noted "You are thinking way out of the box. It seems all you want to  do is apply special formatting to an XML element called "saleprice". Why  not use the regular functions for that?"

                   

                  I did refer to "Automating InDesign with Regular Expression" by Peter Kahrel. The text I want to format does not always follow the same pattern: the location of "saleprice" text will vary between the multiple text frames on a page.

                   

                  That is why I thought, and was hoping, that I could identify the text via the XML tags and modify it via GREP..

                   

                  Thanks to both of you for your help on this.