xslt

Counting nodes in XSLT whose parent nodes have certain attributes

I have XML like this: <exam> <section name="SampleSection1"> <attributes> <variable_name data_type="String" value="SCORE"/> </attributes> <item name="SampleItem1-1"/> <item name="SampleItem1-2"/> <item name="SampleItem1-3"/> </section> <section name="SampleSection2"> ...

Get a specific XML node's position with XPATH?

Let me start by saying I know about position() but I can't seem to figure out how to make it work in this context. What I'm trying to do is iterate through my body of text and find all images. These will be turned into links that say "Figure 1" and so on. The number is provided by the position() of a corresponding node in a different no...

Does libxslt have a feature for splitting a document into multiple documents?

Looks like libxslt does not support XSLT 2.0, and xsl:result-document. Is there a way to mimic xsl:result-document using libxslt, or xsltproc? ...

XSLT Self Closing Tags WITH style

I'm writing some XSLT to render the output of a Rich Text Box in an infopath form. Occasionally I'll get something like this in the output: "<span style="font-size: 11px" class="Apple-style-span" />" And it breaks EVERYTHING. I can't use: <xsl:if test="string(.) != '' or descendant-or-self::/@[string(.)]"> because technically it i...

is it possible to send email as xml data with xslt?

Hi All, is it possible to send user and email in xml format that is formatted using xslt styles? ...

xslt for-each-group question

I have a xml need to group by category I try to use <xsl:for-each-group select="ItemList/Item" group-by="CategoryID"> How can I get the CategoryName, CategoryID or any information related to Category during the transformation? Original XML <ItemList> <Item> <CategoryID>1</CategoryID> <CategoryName>Book</CategoryName> <...

Referencing an XSL Stylesheet within another

I have a XSL stylesheet that I wish to compile into a dll using the xsltc.exe command. The issue that I am facing is that there is a common stylesheet that is being used and my styleheet is referencing that stylesheet using the xsl:include tag as shown below: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...

extract and move nodes via XSLT

I need to transform the incoming XML so that I can extract all "item" with "categorie" is equal "two" and move these into a separate "records" node with an attribute initialized as type="two". Here's a sample of the incoming XML. <datafeed> <records type="one"> <purchases> <items> <item> <categorie...

Xalan (XSLT) translate method translating more than it should.

Hi everyone, I seem to be having an issue with Xalan's translate method. I have the following code: translate(translate(string(name),'&lt;sup&gt;',''),'&lt;/sup&gt;','') This is used to remove <sup> and </sup> from string(name). Unfortunately when I do that, it seems to remove s, u and p from the names as well. So names like sony Bra...

Can I tranform XML to HTML in SQL Server?

I have a query that returns data as XML using the "for XML Clause" and then sends the result as the body of an email like so. Declare @messBody as nvarchar(max) Set @messBody = (Select * from tablehere where state = 1 for xml Auto) Begin Exec msdb.dbo.ap_send_dbmail @profile_name = 'ProfileNameHere' @recipients = 'simon@ex...

XSLT: How to check if certain nodes are all equal in one parent

I am trying to think of a XSL snippet that would check if a class has all the students with the same lastname. It yes, then (do anything like) print "all lastnames are same" else print "all lastnames are not same". It really doesn't matter what to print. I am just trying to find the right logic for it. Here is my sample XML: <root> ...

How would I rewrite this XSLT to C# and get the same results?

Basically, I have some xslt that I have written and I want to migrate the same functionality to C#. I know I have to use XPath and such, but I am having trouble properly accessing the right nodes and attributes. Here is the functionality I want to translate: <xsl:for-each select="$mediaNode/node"> <xsl:variable name="mediaNodeNam...

select all matching nodes using xpath and xslt (without additional templates or for-each)

Hi! I have a particular problem that I can't seem to solve. Is it possible to select all nodes using xpath and xslt without the use of additional templates or for-each? Example xml: <aaa id="11"> <aaa id="21"></aaa> <bbb id="22"> <aaa id="31"></aaa> <bbb id="32"></bbb> <ccc id="33"></ccc> <ddd ...

Strip leading spaces only

Given element: <comments> comments go here </comments> How can I strip what may be multiple leading space characters. I cannot use normalize space because I need to retain newlines and such. XSLT 2.0 ok. ...

XSLT Sorting with

I am using the Muenchian method to group data from my xml document from Marc's solution and I am trying to sort the data within each group without much success. I have tried the following, but no sorting is carried out: replaced: <xsl:value-of select="MemberLastName"/> with <xsl:apply-templates select="MemberLastName" > <xs...

XALAN register Extension Function like in SAXON

Hi, i want to transform a XML by XSLT with XALAN. Now i want to use a extension-function, this function have to be added in JAVA source like in SAXON: Method: TransformerFactory tFactory = TransformerFactory.newInstance(); Configuration c = ((net.sf.saxon.TransformerFactoryImpl) tFactory).getConfiguration(); c.registerExtensionFunctio...

remove xmlns attribute from namespace prefix node

Hello everyone, I'm trying to use XSLT to create Edge Side Includes html blocks. Here is a sample XSLT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:esi="http://www.edge-delivery.org/esi/1.0" exclude-result-prefixes="xsl esi"> <xsl:output me...

Setting background color for a text in XSLFO

Hello Im very new to the XSLFO. I have a requirement to color a text entry based on some condition. which i do using the snippet <fo:inline color = "red"> <xsl:value-of select="."/> </fo:inline> With the above snippet i am able to set the forecolor of the text to RED. My question is how to set the background color for the same. ...

XSL Skipping Child Element

I want to skip the child element from following xml <person id="101"> <name>XYZ</name> <last-name>XXX</last-name> </person> <person id="101"> <name>YYY</name> <last-name>BBB</last-name> </person> Assuming I want to skip last-name and here is my code <xsl:template match="/"> <xsl:apply-templates select="//person [no...

can you call a template within a template in xsl

can you call a template within a template? for example: If I was wanting to use <xsl:choose> <xsl:when test="//*[local-name()='RetrieveCCTransRq']"> <xsl:call-template name="SOAPOutput"/> </xsl:when> </xsl:choose> <xsl:template name="SOAPOutput"> <SOAP-ENV:Envelope> <SOAP-ENV:Body> <OutputPayload> <TotalTr...