xslt

change variable value in xsl

I'm having a problem with XSL variables. I know that once declared, the value of the variable cant be changed. But I'm facing a rather strange problem and I cant possibly change the XML output, instead figure out if its possible with XSL itself. I'm using xsl:for-each to loop over some data in the XML. The data being looped can be of ...

How to assert for each child one element is present or not

<ClinicalDocument> <entry> <substaceAdministration> <effectiveTime></effectiveTime> </substaceAdministration> </entry> <entry> <substaceAdministration> <effectiveTime></effectiveTime> </substaceAdministration> </entry> <entry> <substaceAdministration> </substaceAdministration> </e...

Calculating a formatted string's width & height in C#

Hi, I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML from a database. Because of complex rules in terms of paging for this document, calculations are done in determining the page breaks when I generate the XML that will be consumed by the XSL. I have noticed that I've been getting inconsistent results with ...

problem using select : "//somenode"

Hey everyone im trying to use <xsl:for-each select="//node1"> in my xsl the problem is that it gets all the nodes name node1 together and not passing them one by one (as for each should be) just for you to know im using // pattern becuase my xml changes and i do need to find inside some node the node1 hope you can help... ...

template match using xpath query

hey everyone my xml has some node with same attribute and i would like to pull them using some xpath hope you can help so it basically looks like this <myxml> <something Type="AT_SAS_6"/> <something Type="AT_SAS_50"/> <something Type="AT_SAS_200"/> </myxml> i know that if it was on the name i could do something like <xsl:template ...

VB.Net apply XSL transformation to XML file

Hi there I have got some XML which is built by my application. This XML is dropped to an XML file, which I then wish to apply an XSL stylesheet to in order to convert it to a HTML page. However, every time, it just keeps coming out with the original XML rather than the transformed HTML Here is the XML: <firelist> <visitor> <Titl...

XSLT function to validate date in the format of YYYYMMDD

I am looking for suggestions to validate an XML element which holds the date and i need a function in the XSLT to validate whether it is in YYYYMMDD format or not. ...

XSLT - boolean true if attribute value character length greater than 10

I attempted this to count the total characters of my title attribute value, but it didn't seem to evaluate as I intended it to: <xsl:if test="count(@title)>10"> <xsl:attribute name="class">double-line</xsl:attribute> </xsl:if> I also tried to append /text() to @title. It looks like I'm still off. Any suggestions? ...

XSLT on SSRS report

I want to translate an XML file with data like the following: <FlatData> <Details1_Collection> <Details1 Customer1="Customer" Total1="3" /> ... </Details1_Collection> </FlatData> The data I am interested in is the attributes and their values in each Details1. The problem is that these attributes are not necess...

Firefox not running jQuery for XHTML output

Okay, I did a crappy job of describing the issue in my previous post. I think the discussion got sidetracked from the core issue - so I'm going to try again. Mea Culpa to Elzo Valugi about the aforementioned thread. I have an XML file: <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="wtf.xsl"?> <Paragraphs...

User Documentation from XML

Hello there, I have my nice set of XML files for a user manual, which I already transform to HTML to make the online manual (simil CHM) with XSLT. Now, I'd like to make a printable user manual from the same set of XML files. I'd like to generate an ODT or directly a PDF file, but I didn't find any "quick-and-simple" tool to do that. T...

Calculate number of keywords in XSLT

Let's say I have the following XML structure: <entry> <countries>USA, Australia, Canada</countries> </entry> <entry> <countries>USA, Australia</countries> </entry> <entry> <countries>Australia, Belgium</countries> </entry> <entry> <countries>Croatia</countries> </entry> I would like to count number of instances for each coun...

Getting value 0 or 1 from count() of XSL nodesets

I have a bunch of nodesets where I want to return "1" instead of "true" when there are more than one hit on count($mynodeset) Is there more compact/smarter way to to do this in XSLT 1.1? <xsl:variable name="x5" select="count($mynodeset) != 0"/> <xsl:variable name="z5"> <xsl:choose> <xsl:when test="x5 = 'true'">1</xsl:w...

How to work with an embedded XML and XSL file

I am trying to create an embedded file containing both XML and XSL. The test is based on "XML and XSL in one file" on dpawson.co.uk. The source looks like this: <?xml-stylesheet type="text/xml" href="#stylesheet"?> <!DOCTYPE doc [ <!ATTLIST xsl:stylesheet id ID #REQUIRED> ]> <doc> <xsl:stylesheet id="stylesheet" ver...

For-each inside another For-Each and access a attribute defined in the first loop using the value of the second

For-each of a collection of headers and find a certain attribute in another collection of Items. If I have something like: <ROOT> <Listings> <Listing> <Headers> <Header width="3cm" value="UserName" /> <Header width="3cm" value="MobileAlias" /> <Header width="3cm" value="Name" /> <Header wid...

How to transform a number (1,2,3, etc) into an ordinal number (1st, 2nd, 3rd, etc) using xslt

Pretty simple question, how can I transform a number (1, 2, 3, etc) into a print friendly ordinal number (1st, 2nd, 3rd, etc) using xslt? Currently the following works for 1-20 but we may be seeing larger sets of entities getting ranked soon: <xsl:template name="FormatRanking"> <xsl:param name="Value"></xsl:param> <xsl:choose> <xs...

DTD Entities vs XML-Schema Elements

Hi, using an in Document DTD I did the following: file.xsl: <!DOCTYPE xsl:stylesheet[ <!ENTITY red "rgb(255,0,0)"> ]> <xsl:stylesheet> [...] <xsl:attribute name="color">&red;</xsl:attribute> [...] </xsl:stylesheet> I wanted to change everything to XML-Schema. So I tried: file.xsd: <xsd:schema xmlns:xsd="http://www.w3.o...

xsl truncate a decimal

Hi I have an xml file with an xsl that I am trying to change the way the numbers are displayed. In the xml all the numbers are in the format 00:12:34 I need to remove the first 2 zeros and the colon and just display 12:34 I am not sure if I use a substring or a decimal format. I am pretty new to this so any help would be marvellous....

XSLT Stylesheet: Changing text to upper case

I am using an XSLT stylesheet to create an Excel document from an XML file. One of the values that I am pulling in I want to display as upper case. How is this possible? ...

Find number of characters matching pattern in XSLT 1

Hello, I need to make an statement where the test pass if there is just one asterisk in a string from the source document. Thus, something like <xslt:if test="count(find('\*', @myAttribute)) = 1)> There is one asterisk in myAttribute </xslt:if> I need the functionality for XSLT 1, but answers for XSLT 2 will be appreciated as w...