xslt

XSLT for-each performance? (sitecore)

I have the following for-each select; "sc:item($myFolder,.)/descendant::item [@template='myTemplate']". According to Sitecore's own profiler this returns crawls through 16.000 items, although there are only approx 1700 items with the mentioned template. Could this be optimized - if so, how? ...

Truncating HTML attribute value in SharePoint DataFormWebPart

Hello, I'm using DataFormWebPart to display all announcements in the SharePoint site collections. It uses SPDataSouce with DataSourceMode set to CrossList and it works OK. The text of the announcement comes from the XML attribute: <xsl:value-of disable-output-escaping="yes" select="@Body" /> Now I need to limit this text to, say, 250...

How to convert XML to text file using XSLT

I'm trying convert an XML file to text using XSLT, but I don't have any experience using XSLT. Here's a sample XML file: <DOC xsi:noNamespaceSchemaLocation="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; <DOC_REQUISITES DOC_DATE="2009-04-23" DOC_NO="99999999"/> <DOCID TradeDate="2009-04-23" Weekday="Monday" MainFirmId="Z...

XSL: Assigning the result of position() to a variable

I am trying to assign the position of an element like this: <xsl:variable name="offset" select="ancestor::myparent/position() * 8"/> I am trying to show the result of the calculation in the output, so using a selector is not enough. xsltproc generates the following error: XPath error : Invalid expression ancestor::myparent/position()...

Defining XSLT Variables dynamically using xsl:choose

Within my XSLT spreadsheet, I need to define an xsl:variable with one value or another depending on the value of an xml node. The code just below shows what I'm trying to do. I would like to define multiple variables this way. A major issue is that in order to choose a variable value based on the node value of each item, the choosing mu...

Is there a tool like doxygen for XSLT?

Does someone know a tool, that can extract the code structure from undocumented xsl files? I know there is XSLTdoc, which can extract documentation elements from xsl files to build html reference pages. But for undocumented xsl files, XSLTdoc's output is rather useless. Doxygen is able to produce valuable output even if the code is not...

How to extract unique characters from a string using XSLT 1.0 ?

one of the toughest challenges I have ever faced in XSLT designing .. How to copy the unique characters in a given string .. Test xml is: <root> <string>aaeerstrst11232434</string> </root> The output I am expecting is: <string>aerst1234</string> ...

XSLT 1.0 add namespace + xsi:type to element

Hi I want to go from this : <detail> <BusinessError> <environment>Test</environment> <businesserror> <BusinessCode>my_businesscode</BusinessCode> <BusinessMessage>my_businessmessage</BusinessMessage> </businesserror> </BusinessError> </detail> To this (only the businesserror element is of interest) ...

How to access variable in CDATA from XSLT ???

Hello All, I am using XSLT Transformation and need to put some data in CDATA section and that vale is present in a variable. Query: How to access variable in CDATA ? Sample Given Below: <xsl:attribute name ="attributeName"> <![CDATA[ I need to access some variable here like *<xsl:value-of select ="$AnyVarible"/>* ]]> </xsl:att...

Typing an XSLT template/function as a sequence constructor?

Very simply, is it possible to type an XSLT template or function to return a named sequence constructor? e.g. in FpML, there is the Product.model group, which simply contains two elements (ProductType and ProductId). I'd like to be able to create a typed template which returns that sequence, but have no idea what the "as" attribute shou...

Matching expression inside of a data section of an xml element using xsl

Hi I am usually programming in c++ so XML/XSL/XPATH is not my strong side, but I need to do a transformation and I cannot seem to find a good way of doing it. We have an xml file that is formatted like this: <outer> <element/> <other_element/> <message pri="info"> [[!CDATA Error: something is not working]] </message> <me...

XSLT - Remove currency formatting and check if number, otherwise pass as string

I need to remove currency formatting from a string, but my problem is that the field sometimes contains currency and sometimes it is a string of text. So it could be: $20 123,000.00 $123,000.00 Hello World! ...

How to change the footer image in each page of xsl-fo according to certain condition

Is there a way to change the footer image in each page of xsl-fo according to certain condition? ...

How sort elements and store them in a variable, XSLT

Hello everyone, I was wondering whether it's possible to sort some elements first and store them (already sorted) in a varible. I would need to refer to them thought XSLT that's why I'd like to store them in a variable. I was trying to do the following, but it doesn't seem to work <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/...

What's the situation with XSLT and XPATH in modern browsers?

I'm writing javascript code to traverse and manipulate deeply nested XML documents. With modern browsers, is there still a need for crossbrowser libraries like: sarissa ajaxslt As far as I know, without using one of these there won't be any XPath in IE with ActiveX disabled. And a simple wrapper is needed for both XSLT and XPath to d...

Efficient merging of multiple, large xml files into one

I searched the web and I searched stackoverflow up and down. No solution. Although I found solutions how to do this within pure xslt here. But the problem is that the resulting xml will be several hundred MB large. So I must do this with SAX in Java. (please no xslt solution, although I tagged it with xslt ;-)) Let me explain with more...

Pass string into template parameter which expects node?

So, I have an XSLT template which expects a node set as a parameter and uses this as display text. However, sometimes this node is empty in the XML and I want to pass default display text instead of the display text not showing up instead: Works: <xsl:call-template name="myTemplate"> <xsl:with-param name="parm1" select="//element"...

More performant XSLT -- Selective Inclusion in Output

I have created a stylesheet that is supposed to selectively copy the contents of an XML document so that I can strip out data that we do not need. I have provided 2 examples below and the stylesheet that we are currently using to do this. The stylesheet works, but I think there is probably a better way of doing it because in the curren...

XSLT counting "identical" elements based on a subset of descendants

I'm transforming XML to HTML. In part of the XML, I need to count elements that seem "identical" when specific descendants are compared, while other descendants and any attributes must be ignored. Here's a simplified example of my XML. The real thing is much more complicated; I've just removed elements that aren't relevant to the counti...

Getting Variable values out of and XSLT file.

I wanted to find out if there is a way of getting a parameter or variable value out of an XSL file. For example, if I have the following: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="username" select ="usertest"/> <xsl:variable name="password" select ="pass"/> <!-- ... --> </x...