[xsl] testing parameter type

Subject: [xsl] testing parameter type
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 8 Aug 2026 23:38:46 -0000
Hello --

So I have a stylesheet with a parameter.

Usually, the stylesheet is being called by the transform() function from
another stylesheet and the value of the parameter is a document node.

Sometimes, for testing, the stylesheet is being called directly and the
value of the parameter is a string with a file path in it where the string
gets passed to doc() to get the document.

I can use

if (empty($param/*)) then doc($param) else $param

in the select for a variable which the rest of the stylesheet then uses
to distinguish these two cases when the parameter isn't typed.

If I type the parameter as item(), testing with

$param instance of document-node()

will work; the string doesn't default to being a document node now that
the param is typed.

So there are at least two working approaches but I can't help thinking there ought to be a better way to do this.

Anyone got any suggestions?

Thanks!
Graydon

--  
Graydon Saunders  | graydonish@xxxxxxxxxxxx
\xDE\xE6s ofer\xE9ode, \xF0isses sw\xE1 m\xE6g.
-- Deor  ("That passed, so may this.")

Current Thread