Subject: Re: [xsl] Is there any benefit to creating a variable and specifying as="xs:string"? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 9 Jun 2024 09:25:11 -0000 |
I have this xsl:param at the top of my XSLT program:
<xsl:param name="ICAO" />
Is there any benefit to adding this "as" clause:
<xsl:param name="ICAO" as="xs:string"/>
That "as" clause says the ICAO param is a string value. Well, everything is
a string. These are all strings -- '123', 'true', 'http://www.example.com', '01101' -- all of which should not be used to populate the ICAO param. It seems to me that adding the "as" clause provides zero benefits. In fact, it has disadvantages: it makes the code more verbose, it requires more typing. Do you agree that adding the "as" clause provides no benefits?
Bonus question: The value to populate the ICAO param should be a 4-letter,
uppercase value, such as KBOS. Is there anyway to express that requirement/constraint in the "as" clause?
Perhaps in XSLT 4 as="enum('KBOS')" Of course an enumeration requires you to be able to list the possible values.
In schema-aware XSLT 2 or later I think you might be able to import a schema that defines a type with some restrictions so that some of your constraints are ensured and use that type in the "as" attribute.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Is there any benefit to creat, Roger L Costello cos | Thread | Re: [xsl] Is there any benefit to c, Martin Honnen martin |
[xsl] Is there any benefit to creat, Roger L Costello cos | Date | Re: [xsl] Is there any benefit to c, Martin Honnen martin |
Month |