Skip to main content
1-Visitor
August 10, 2015
Solved

Stylesheet error: "Prefix 'child' not declared"

  • August 10, 2015
  • 2 replies
  • 1768 views

A user reported an issue when trying to insert a graphic using a FIG tag. The exact scenario is shown here. The user has inserted a graphic using FIG and TITLE. Our Fig element logic looks for: if fig in procinfo, else if fig in li, else fig everywhere else.

I also included what I believe is the result of that logic, the specific XPATH language in use for this situation, "Fig Everywhere Else". The error does not seem to actually affect anything since the user can still create the topic, use in publication structures, etc, but we are worried that it may be a bigger issue down the road. I am relatively new to Styler, and I am not sure what to even check for to start debugging this issue. Help!

The actual error reads:

Cannot evaluate XPath expression in stylesheet [A30282] Invalid XPath expression: The prefix 'child' is not declared. Element: fig: Xpath expression: (not(Child:title/text()))

Child error.jpg

Xpath expression.jpg

    Best answer by ClayHelberg

    Hi Jackie--

    There's an error in your XPath expression. You are missing a colon, so the interpreter thinks you mean "child" as a namespace prefix instead of an axis specifier. To fix it, change the condition to read:

         not(child::title/text())

    (Note there are two colons there.)

    --Clay

    2 replies

    18-Opal
    August 11, 2015

    Hi Jackie--

    There's an error in your XPath expression. You are missing a colon, so the interpreter thinks you mean "child" as a namespace prefix instead of an axis specifier. To fix it, change the condition to read:

         not(child::title/text())

    (Note there are two colons there.)

    --Clay

    16-Pearl
    August 11, 2015

    Clay is 100% correct. It is also worth noting that the child:: axis is the default for unqualified element names in XPath, meaning you can substitute "not(title/text())" and get the same result.

    BTW it is actually very unusual to see child:: in XPath expressions as it can make them unwieldy (e.g. /child::doc/child::chapter/child::section/child::para as opposed to /doc/chapter/section/para).

    jsage1-VisitorAuthor
    1-Visitor
    August 21, 2015

    Thank you! I made the first suggested change for now and will see how that goes once it is in place in the PE. But I noted your comment for future improvements. I inherited another's work and am a relative newbie with the stylesheets, so I appreciate that pearl of wisdom!