xsl-list
[Top] [All Lists]

RE: Using a pre-processor for dynamic inputs

2004-09-13 09:14:01
At 05:21 AM 9/11/2004, Mike wrote:
(a) if the inputs are fairly predictable in structure, you can write your
stylesheet to interpret the inputs. For example, you might supply a
parameter to the stylesheet of the form:

<conditions>
  <condition>
    <attribute>name</attribute>
    <value>robin</value>
  </condition>
  <condition>
    <attribute>size</attribute>
    <value>small</value>
  </condition>
</conditions>

Since the OP is a newbie, I hasten to add that simple cases of this are often handled with string-valued parameters, not node-trees, so you could say for example

saxon in.xml stylesheet.xsl name='robin' size='small'

and get the same effect. It's easy to do, requires a little less overhead, and (like the more complex solution) binds the values at run-time, when they're required.

It was also subsequently written:
Or even better, put the condition in the match pattern:

  <xsl:template
   match="Species[Extinct='False' and Genus_Name='Casuarius']">
      <p>species name is <xsl:value-of select="Species_Name"/></p>
  </xsl:template>

  <xsl:template match="Species"/>

Yeah, I should have explained this is what I wanted, but couldn't get it to work right (because I didn't have the second template)!

But unfortunately, match patterns like match="Species[Extinct=$extinct and Genus_Name=$name]" aren't legal in XSLT 1.0 (no variable or parameter references allowed there), so you're back to the in-template conditional test....

Cheers,
Wendell



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================



<Prev in Thread] Current Thread [Next in Thread>