xslt date format change (dd-mmm-yyyy) - xslt-1.0

I am using the below code to show the current date in xslt program.It's working fine With the date format yyyy-mm-dd. But i need the format dd-mmm-yyyy. Please help me to do this.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:cs="urn:cs"
>
<xsl:value-of select="cs:datenow()"></xsl:value-of>

You have tagged your question as XSLT 2.0 so I would expect you to simply get the current date with the current-date function http://www.w3.org/TR/xpath-functions/#func-current-date and to format it with the XSLT 2.0 function format-date http://www.w3.org/TR/xslt20/#format-date.
So basically format-date(current-date(), '[D01]-[MN,*-3]-[Y0001]') gives a format like 11-JUL-2013. Depending on your needs (I am not sure what the format mmm stands for, as most date formatting routines define their own patterns) you need to adapt the "picture string" argument of format-date, see the documentation I linked to.

Related

Using Xsl <fo:external-graphic> to hand over data

Is there a way in XSL 1.0 to hand over variables or parameters using XSL fo:external-graphic like I would do when I'm using xsl:call-template
I know how I could work around the problem but I just wanted to know if there is a way I am not seeing.
If your SVGs are small enough, you could use fo:instream-foreign-object. (If the SVGs are very large, the size of the XSL-FO file might become a problem.)
main.xsl:
<xsl:import href="svg/svg_graphic.xsl" />
<xsl:template match="some/context">
<fo:instream-foreign-object>
<xsl:call-template name="make-svg">
<xsl:with-param name="param-a" select="..." />
</call-template>
</fo:instream-foreign-object>
</xsl:template>
svg_graphic.xsl:
<xsl:template name="make-svg">
<xsl:param name="param-a" select="..." />
<svg:svg>
...
</svg:svg>
</xsl:template>
<fo:external-graphic src="svg/svg_graphic.xsl" /> is not going to work. Inside your XSLT stylesheet, the elements in the XSL-FO namespace are just literal result elements. They are copied to the result tree, and they are not otherwise acted on by the XSLT processor. XSLT-specific attributes on literal result elements (where the attribute in the XSLT namespace and is defined as meaning something when used on literal result elements) are acted on by the XSLT processor. Attribute value templates ({...}) in attribute values of literal attributes (and some XSLT-defined attributes) are acted on by the XSLT processor.
There is no XSLT 1.0 way to get the XSLT processor to run another stylesheet based on the value of an XSL-FO-defined attribute.
There's also no XSLT 1.0 way to generate multiple result documents from one run of a stylesheet. Your XSLT processor probably has a processor-specific (or EXSLT) way to do that. The extension, if it exists, might not let you generate part of the XSL-FO result document, generate an SVG result document, and then go back to generating more of the XSL-FO document.

Special characters in BPEL

This is regarding the common problem we face in Middleware( Oracle SOA 11g). We have one source value like "SEBẪSTIN" but while reading this value the final output value is appearing as "SEB�STIN"
yes..I know, I can use CDATA for not parsing the value. But it is not working.
I have referred to the following post. But no luck.
How to use <![CDATA[]]> in XSLT?
Could you please let me know the correct syntax using CDATA. My xslt tag looks like this
<ns2:Firstname>
<xsl:value-of select="imp1:FIRSTNAME"/>
</ns2:Firstname>
OR
do we have any other option to handle this character.
version details :
Oracle SOA 11g
Jdeveloper: 11.1.1.7.0
BPEL: 2.0
XSLT: 1.0
Any help would be appreciated.
Thanks,
Abhi

Can I exclude a specific file name with Wix Heat using transforms?

Is it possible to exclude a specific file name with Wix using transforms?
I can exclude files that contain a certain string, but this excludes any file name matching the string. For example I can exclude file.exe with the following;
<xsl:key name="fileexe-search" match="wix:Component[contains(wix:File/#Source, 'file.exe')]" use="#Id"/>
but this will also exclude files with file.exe in their name, like file.exe.config.
Thanks.
Looks like you should use ends-with instead of contains. But ends-with does not exist in XSLT 1.0. :)
This answer gives enough details to get the idea of how to implement it. Basically it is a combination of substring and string-length functions.
Besides, you should also consider normalizing the casing before comparison. That is, it is better to lower-case (or upper-case) both strings - the original and the one it ends with. This post can give you an idea of how to do it.
Keeping all this in mind, you will end up with something similar to this:
<!-- The starting backslash is there to filter out files like 'abcfile.exe' -->
<!-- Besides, it's lower-cased to ease comparison -->
<xsl:variable name="FileName">\file.exe</xsl:variable>
<xsl:variable name="ABC">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:variable name="abc">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:key name="fileexe-search" match="wix:Component[translate(substring(wix:File/#Source, string-length(wix:File/#Source) - string-length($FileName) + 1), $ABC, $abc) = $FileName]" use="#Id"/>
Although the answer provided by #Yan works I prefer to use C# which is simpler to use.
<xsl:stylesheet version="1.0"
...
xmlns:my="urn:my-installer">
...
<msxsl:script language="C#" implements-prefix="my">
<msxsl:using namespace="System.IO" />
<![CDATA[
public bool EndsWith(string str, string end)
{
if (string.IsNullOrEmpty(str))
return false;
if (string.IsNullOrEmpty(end))
return false;
return str.EndsWith(end);
}
]]>
</msxsl:script>
...
Usage example:
<xsl:key name="ignored-components-search" match="wix:Component[my:EndsWith(wix:File/#Source, '.pssym')
or my:EndsWith(wix:File/#Source, '.pdb')
or my:EndsWith(wix:File/#Source, '.cs')
or my:EndsWith(wix:File/#Source,'.xml')
]" use="#Id" />

Unrecognized XSLTC extension 'http://exslt.org/common:document''

<xsl:stylesheet version="1.0" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"
<exsl:document href="filename">
<xsl:value-of select="."/>
</exsl:document>
exsl not working with XSLT 1.0, I want to create multiple files using XSLT 1.0 only. How to do it ?
I want to create multiple files using XSLT 1.0 only.
XSLT 1.0 as such does not allow for multiple result documents. You will need an XSLT 1.0 processor that either supports the EXSLT <exsl:document> element or provides a similar feature as a custom extension. Or program multiple conversions, using the calling application.

XslCompiledTransform with XSLT 1.0 ms:format-time() Timezone

I am working with an XslCompiledTransform object and try to parse a DateTime object. It works but only shows the GMT date.
When I debug the code, the object has the correct value (GMT+2)
I am using this in the XSLT:
ms:format-time(order/#orderDate, 'H:m', 'NL-nl')
The output has a two hour difference with the correct value.
Can this be solved using XSLT 1.0 and the default .Net 4 framework methods. (C#)
Edit: Can this be solved without adding code to the XSLT https://groups.google.com/d/topic/microsoft.public.xsl/1mPHhh6F62o/discussion
Edit2: Seems that more people have problems with formatting time in XSLT 1 With different timezones: http://forums.tizag.com/showthread.php?t=17429
Ok, here it the top of my XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
xmlns:user="urn:my-scripts">
<xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
<ms:script language="C#" implements-prefix="user">
<![CDATA[
public string correctTime(DateTime dt)
{
return dt.ToLocalTime().ToString("HH:mm");
}
]]>
</ms:script>
<xsl:template match="/">
...
and further down the XSLT some HTML markup and using the method mentioned above:
<tr>
<td>Tijd:</td>
<td>
<xsl:value-of select="user:correctTime(order/#datum)"/>
</td>
</tr>
Holland has now (because of daylight saving time) GMT + 2
without the use of this method it just converted my value to GMT
So there was a 2 hour difference. The 1 hour difference we had before wasn't noticed. But because it is now 2 hour, it got to our attention :)