Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Detecting upper case

From: "Dimitre Novatchev" <dimitren@---.---.-->
To: NULL
Date: 7/11/2006 9:51:00 PM

Here's what I believe is a "clean" pure XSLT solution (the XSLT 1.0 solution 
is quite similar):

When the following transformation is applied against any xml document (not 
used):

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://fxsl.sf.net/"
xmlns:testmap="testmap"
exclude-result-prefixes="f testmap"
>
   <xsl:import href="../f/func-str-dvc-map.xsl"/>

   <xsl:variable name="vCaps" select=
   "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

   <!-- to be applied on any xml source -->

   <xsl:variable name="vTestMap" as="element()">
     <testmap:testmap/>
   </xsl:variable>
   <xsl:output omit-xml-declaration="yes" indent="yes"/>

   <xsl:template match="/">

     <xsl:value-of select="f:str-map($vTestMap, 'DocumentLogicalType')"/>
   </xsl:template>

    <xsl:template name="double" match="testmap:*"
     mode="f:FXSL">
      <xsl:param name="arg1"/>

      <xsl:value-of select=
       "concat(if(contains($vCaps, $arg1)) then ' ' else '', $arg1)"
       />
    </xsl:template>

</xsl:stylesheet>

the wanted result is produced:

" Document Logical Type"


Cheers,
Dimitre Novatchev


"Anthony Jones" <Ant@y...> wrote in message 
news:uemLNnTpGHA.4424@T......
>
> "FinallyInSeattle" <lori.pearsall7@g...> wrote in message
> news:1152570079.433737.295700@p......
>> I have the situation where I have a document element that looks like
>> the following:
>>
>>  <field key="DocumentLogicalType">Submission</field>
>>
>> I'd like to render "DocumentLogicalType" as "Document Logical Type" -
>> basically inserting a space whenever an upper case character is
>> encountered.  How do I detect upper case (as opposed to a translation)?
>>
>> Thanks in advance!
>>
>
> Mukul's code well demonstrates the problems of implementing a 'procedure' 
> in
> xsl.
>
> If all you have is a hammer everything looks like a nail.
>
> If you absolutely have to implement this in XSL then the solution works 
> but
> if you have other choices then perhaps those choices would be better.
>
> A few of Ideas:-
>
> If your target processor is MSXML then embedding some script in the XSL 
> that
> will handle this much more cleanly.  MSXML and possibly others support
> adding objects to the processor to supply extended functions.
>
> Pre-process the XML adding an attribute contain your prefered display 
> string
> or replace the value with you prefered string.
>
> Anthony.
>
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent