Skip to main content
Inspiring
May 20, 2011
Question

Use InDesign GREP to Identify and Modify XML Tagged Text?

  • May 20, 2011
  • 2 replies
  • 3459 views

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.

This topic has been closed for replies.

2 replies

Jongware
Community Expert
Community Expert
May 24, 2011

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?

John Hawkinson
Inspiring
May 24, 2011

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.

Jongware
Community Expert
Community Expert
May 24, 2011

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.)

John Hawkinson
Inspiring
May 24, 2011

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!