Date: Sun, 13 Dec 2009 17:40:44 -0500
From: "G. Ken Holman"<gkholman(_at_)CraneSoftwrights(_dot_)com>
First "xsd:bool" is incomplete and would have to be "xsd:boolean".
And while it won't affect this particular example, the "protected"
way of doing what you are doing with strings is to add a space at the
start and end of your string with the tokens, and then add a space to
the start and end of the token being searched.
Right. It does effect my example as xsd:date is a substring of
xsd:dateTime. How can I add a space before and after @type in
<xsl:template match="xsd:element[contains($KnownXSDTypesMap, @type)]">
I tried ' @type ' but it doesn't work. Putting, as a test, single quotes
around @type like this '@type' does not work either what would suggest
that @type is treated literally when quoted in such a way.
In XSLT 2 you might consider something like:
<xsl:param name="KnownXSDTypes" as="element()*">
Very nice. It solves problem from my original post.
However, I really need two things;
1. test if a value of a type attribute is on the list
2. if it's on that list I need to map it to some predefined string being
Your idea solves the first problem but I still need to solve the second
one. And the best solution would be to use a map to solve both problems
at the same time. Do you agree?
I made generic map template which looks like this
<xsl:analyze-string select="$map" regex="([^\s]+)/([^\s]+)">
<xsl:if test="regex-group(1) eq $key">
with maps looking like this
<xsl:param name="KnownXSDTypesMap">xsd:date/DATE xsd:dateTime/DATETIME
It works but you can't have slash sign ('/') in neither key nor value.
That's the problem with encoding a map as a string. One would have to
use xml elements for this to be truly generic. Something like
<entry key='foo' value='bar'/>
but I don't know how to include and use definition such as this one in
my xsl file? Further, how to extract all keys and make a set out of them
the same way you showed for xsl:param?
Thanks for your answer and time.
Yes, I saw Michael's reply but wanted to extend the scope of my original
question while replying to your post.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>