[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: problem with fn:contains using xsl:param
Date: Sun, 13 Dec 2009 17:40:44 -0500 From: "G. Ken Holman"<gkholman@xxxxxxxxxxxxxxxxxxxx> Message-Id:<7.0.1.0.2.20091213172539.025d5598@xxxxxxxxxxxxxxxxxxxxxx> First "xsd:bool" is incomplete and would have to be "xsd:boolean". Right. 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)]"> statement? 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: 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 used later. 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:template name="KeyToValue"> <xsl:param name="map"/> <xsl:param name="key"/> <xsl:analyze-string select="$map" regex="([^\s]+)/([^\s]+)"> <xsl:matching-substring> <xsl:if test="regex-group(1) eq $key"> <xsl:value-of select="regex-group(2)"/> </xsl:if> </xsl:matching-substring> </xsl:analyze-string> </xsl:template> with maps looking like this <xsl:param name="KnownXSDTypesMap">xsd:date/DATE xsd:dateTime/DATETIME xsd:boolean/BOOL</xsl:param> 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 <map> <entry key='foo' value='bar'/> (...) </map> 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.
ps. Yes, I saw Michael's reply but wanted to extend the scope of my original question while replying to your post.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|