question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dita2html: warning for undefined element

See original GitHub issue

Currenty when there is no template for an element the default rule will fire that generates some bold text wrapper with yellow background (in dita2htmlImpls.xsl). And the comment even says

><!-- (this rule should NOT produce output in production setting) -->

I think a warning on the console (xsl:message) would be much more appropriate to avoid such an element slip to production. Possibly the behavior could be toggled by a new parameter.

BTW: I didn’t find a way to override this rule by my custom plugin without overriding all other rules as well. So I had to patch the original DITA-OT code. (And hope I remember it when upgrading to a new version.) Is there a better way?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jelovirtcommented, Mar 1, 2017

This has probably been in DITA-OT since 1.0. The correct way would be to use xsl:message to terminate processing completely, since it’s a bug in the code if we ever have to fall back to default templates for elements.

@robander what’s your take, should we treat this as a fatal error in DITA-OT 3.0. It’s not like anyone will actually want the yellow warning in their production output and IMO this equivalent to throwing a RuntimeException in Java for programming errors.

1reaction
robandercommented, Mar 1, 2017

I’m fine with a terminating message.

I can see how overriding a fallback rule that’s explicitly there to match "*" is going to be … difficult to customize, if you want to turn off the message, change it, or insert your own debugging material. Maybe we could handle that with a common mode template, rather than common named template? Go from today’s:

<xsl:template match="*" name="topic.undefined_element">
   .... write out a bunch of ugly stuff ...
</xsl:template>

to a common:

<xsl:template match="*" name="topic.undefined_element">
  <xsl:apply-templates select="." mode="handle-undefined-element"/>
</xsl:template>
<xsl:template match="*" mode="handle-undefined element">
  ... message and termination ...
</xsl:template>

That seems to have the most flexibility, and lets me override that mode to handle fallback in my own way in different transform types?

[All that said: in out-of-the-box cases this should only show up if something is truly broken, like DITA-OT forgot to code for some core element. I’ve only seen it come up on the rare case where somebody puts their own value in @class, or when working on a specialization and I have a typo in @class.]

Read more comments on GitHub >

github_iconTop Results From Across the Web

What repercussions do I get by using an undefined HTML ...
I suppose this is invalid HTML, however both Firefox and Chromium proceed to display the element without any problems or console warnings. I...
Read more >
How to avoid undefined offset error in PHP ? - GeeksforGeeks
Example: Following PHP code explains how we can access array elements. If the accessed index is not present then it gives an undefined ......
Read more >
Undefined index: type in Drupal\Core\Render\Element\Date ...
The undefined index notice is raised for date2, but not date1. Proposed resolution. Change line 65 of core/lib/Drupal/Core/Render/Element/Date.
Read more >
Error: Undefined index: render element - Drupal Answers
If you don't set a variables key for a theme hook implementation, the system defaults to expecting a render element .
Read more >
How to Determine If Variable is Undefined or NULL in JavaScript
To check if a variable is undefined or null you can use the equality operator == or strict ... Try to get non...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found