Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catching stragglers?

Status
Not open for further replies.

thenewa2x

Programmer
Dec 10, 2002
349
US
FYI, I'm using XSL FO.

I have templates for each element that I will be displaying. What I want to do is prevent all of the elements I do not use (but that do exist in the document) from being displayed.

I tried the following but I get a blank document:
Code:
<xsl:template match="*" />

And:
Code:
<xsl:template match="*" priority="2" />

I would think that first one would catch ALL elements that were not already handled by the defined [tt]<xsl:template />[/tt]s.

I am also importing external stylesheets like so:

Code:
  <!-- Import Page Layout -->
  <xsl:import href="page.xsl" />

  <!-- Import Common -->
  <xsl:import href="common.xsl" />

  <!-- Import Hidden -->
  <xsl:import href="hidden.xsl" />

  <!-- Import Information -->
  <xsl:import href="information.xsl" />

  <!-- Import Authors -->
  <xsl:import href="authors.xsl" />

  <!-- Import Reviewers -->
  <xsl:import href="reviewers.xsl" />

  <!-- Import Editors -->
  <xsl:import href="editors.xsl" />

  <!-- Import Sections -->
  <xsl:import href="sections.xsl" />

  <!-- Import References -->
  <xsl:import href="references.xsl" />

You'll notice that there is a [tt]hidden.xsl[/tt] stylesheet. That's the one that for now that has all of the "manually" hidden elements.

I tried changing the imports to includes and also tried changing just the hidden one to include.

---------------------------------------
TINSTAAFL, which is why I contribute.
 
While I am not totally certain I understand your problem, it sounds like you are getting output from elements that is unexplained. If this is true, then you probably getting output from built-in template rules. Some built-in template rules are designed to do nothing, but some are designed to continue recursive processing of a document in the absence of other templates. This is what creates the unwanted output.

Here is an explanation of the built-in rules. You need to make sure you write a template which matches everything that these built-ins match, so that the built-in rules are never invoked.

Does that help?

Tom Morrison
 
My question unnecessarily complex, heh.

Simply put, I need to hide elements that I do not want to display. How would I go about that?

---------------------------------------
TINSTAAFL, which is why I contribute.
 
thenewa2x said:
My question unnecessarily complex, heh.
Exactly what am I to infer from this?

From your original description, you are getting a 'blank document' so you are successfully hiding elements!

If the match="*" is in the importing stylesheet, then it will match at a higher level of precedence than all of the imported templates, so it sounds like it is doing exactly what it is supposed to do.

Probably you should change all your imports to includes. include does not impute an import precedence to the included template.

You were somewhat on the correct track when you changed the 'hidden' to an include, but that did not undo the import precedence imputed to all the other templates that were imported, and thus never invoked.

SO, if this is the case, perhaps you have a complex situation after all? [ponder]

Tom Morrison
 
My apologies, I meant no offense by it. What I meant was that I provided some information that you did not need.

In my first post I mentioned that I did change all of the imports to includes. The thing I failed to mention was that all the elements already had templates defined disappeared while the ones did not, remained. Completed opposite of what I needed.

I looked at Google for use of the [tt]priority[/tt] attribute but I don't quite get what number to use or how to use the attribute at all. Is the higher the number, the lower priority? Do I have to define a priority attribute in every single template?

---------------------------------------
TINSTAAFL, which is why I contribute.
 
Can you post the entire top-level stylesheet? Clearly there is some precedence problem happening here.

Also, are you using something like Stylus Studio or Altova XMLSpy? Both of these products have XSLT debug capability, allowing you to step through a stylesheet more or less a line at a time. Both available for free trial.

priority is considered only to choose among matching templates at the same import precedence. Since it is at the bottom of the template choosing 'food chain' priority cannot be used to overcome import precedence. If the template choosing algorithm gets to priority, the highest numbered template is chosen. Here are the official rules (both sections 5.4 and 5.5).

I think for your description and your previous threads that you should put aside import and priority. Use include to simplify what was obviously a very cumbersome stylesheet.

Tom Morrison
 
Thanks k5tm. The top level stylesheet is pretty much what I provided in my first post with the exception of a large section of parameters for configuring various stylesheets.

I did what you suggested, I changed all of the imports to includes. I also went one step further and I used this to catch the "stragglers":

Code:
  <!-- Hide Stragglers -->
  <xsl:template match="*|@*|node()|text()"
                priority="-1" />

The page still renders as it normally would with the exception of the missing text.

For debugging, I am using Syntext's Serna XML editor. It was not intended for debugging but it renders the page live and I can reload the stylesheet with a single keystroke.

---------------------------------------
TINSTAAFL, which is why I contribute.
 
I have looked at your previous post (Recursive XSL in Serna) using Stylus Studio, and I cannot reproduce the behavior you were describing in that thread.

As to this thread, do the document/stylesheet in the previous thread exhibit the behavior (unwanted output) described here? If so, exactly which output is extraneous? (I might be able to use Stylus Studio's backtracking feature to discover the template that is causing the output.)

Tom Morrison
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top