xslt

Using fn:sum in XSLT with node-set containing null-values

I'm trying to sum up a set of values in an XML using XSLT and XPath function fn:sum. This works fine as long as the values are non-null, however this is not the case. To illustrate my problem I've made an example: <?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ...

XML stores text data with double quotes, JavaScript crashes when retrieving data

Hi all, I am not sure I am going to be able to explain this one right as it may be difficult for me to explain, but I am going to try. I have a web form which it publish the data to a XML file, then it shows the data in another web page. Everything works fine, but when the user types a double quote character, at the time the web page ...

XSLT renders &gt; and &lt; for >< how to do I get around this?

I have some code wrapped in a CDATA tag in an xslt file: <span> <xsl:text><![CDATA[<asp:LinkButton ID ="]]></xsl:text><xsl:value-of select="ID"/> <xsl:text><![CDATA[" onclick="LinkClicked">]]></xsl:text > <xsl:value-of select="."/> <xsl:text><![CDATA[</asp:LinkButton>]]></xsl:text> </span> When it renders in the page i...

How can I perform XSLT transformations in an HttpModule?

I've been trying to implement server-side XSLT transformations as an IIS HttpModule. My basic approach is to install a new filter at BeginRequest that diverts writes into a MemoryStream, and then at PreSendRequestContent to transform the document using XSLT and write it to the original output stream. However, even without performing the ...

Need help with XSLT

I am having an issue with the following, I need the ID to be of each promotiom: Here is my XML: <Promotions> <Promotion> <Category>Arts &amp; Entertainment</Category> <Client>Client 1</Client> <ID>2</ID> <Title>Get your Free 2</Title> </Promotion> <Promotion> <Category>Client 1...

Transform xml structure to another xml structure with xslt

Hello, I have a question. I have the following source xml file: Source xml: <Container> <DataHeader> <c id="b" value="TAG" /> <c id="g" value="Info" /> </DataHeader> <Data> <Rows> <r no="1"> <c id="b" value="uid1" uid="T.A.uid1" /> <c id="g" value="uid1|tag1|attr1|somevalue1" /> </r> <...

XSLT vs MVC vs CSS for flexible mobile/normal layouts

I'm building a new front end for an existing forum project, and I'm undecided on the best route to take for the user front end. The project will be built in ASP.Net 3.5. The requirements are as follows: 1) User selectable themes/templates must be supported - I have forum goers who will want to contribute forum themes, so the layout sys...

ASP.NET controls generated from XSLT do not show up in panel added as a literal control

I have the following code: XElement Categories = new XElement("Promotions", from b in db.GetPromotions() select new XElement("Promotion", new XElement ("Category",b.CategoryName), new XElement("Client",...

Adding relative path for an external graphic in a XSL document?

Hi, first of, I don't know much about XSL. I am using a app called DITA to generate pdfs. One of the things it requires is an overwrite of an xsl file; to add custom styling. I am trying to add an external graphic using a relative path. It doesn't work, unless I supply the full path. Does not work: <fo:block text-align="center" width...

XSLT stylesheets design pattern - separate common and specific templates in different stylesheets

Hello everyone, I was wondering if there is a good approach in XSLT stylesheet design pattern to separate common and specific data representation. I was trying, but got very confused and lost. I would appreciate any advice, tips, hints where I can read up on how to better separate XSLT stylesheets. And also, would really appreciate hel...

Saxon 9 parser and indent="no" - How to remove 'pretty-print'?

Setting indent="no" has no effect with Saxon 9. I guess it is optional in the spec; it isn't really a bug or anything with Saxon. Is there any way to remove the "pretty print"? We save off the XML and it is quite a bit bigger with all the indents. ...

XSLT for displaying XML as HTML

I have an XML document (in a .net C# web app) that I want to display in its simplistic form (similar to IE). I need it to be browser independent (or as much as possible) and have a consistent display. I have tried pushing the xml document through as "text/xml" and this is inconsistent and doens't work in some browsers. http://sources....

Ignore case while doing xsl:sort

I am trying to sort a XML doc using xsl:sort My requirement is to ignore case while doing the sort. xsl:sort have a case-order attribute which helps specify upper-first or lower-first, which is of no help for me. I also tried using translate function, something like this : <xsl:sort select="translate('abcdefghijklmnopqrstuvwxyz','ABC...

(XSLT, Code optimization) How to output the nodes refering to the value of sibling-nodes .. ??

I am transforming XML to XML using XSLT, The objective is to read the value of tag <node1>, if it is null then it must be assigned with the value of <node2>, if incase <node2>, is also null, then default text "Default" has to be assigned .. to both tags .. EDIT: If <node2>is null and <node1> isn't .. then the code shouldn't update <node2...

xslt display attributes in specific order

Hello everyone, I was wondering if there is a way of displaying element's attributes in a specific order, with a use of sequence or somehow establishing an order rather than writing it explicitly. Sorry, explanation is a bit unclear. The example might help: So I have a template: <xsl:template match="Element/@1|@2|@3|@4"> <xsl:if ...

Getting the child node's name of XML using XSL

Hi, I have an XML program in the following structure <Part> <ID>1</ID> <Density>3</Density> <Parameter> <Element>Alloy</Element> </Parameter> </Part> I want to create an XSL which tranforms this XML in such a way that ID 1 Density 3 Element Alloy How I can do that?? Somebody can help me with this... ...

Counting number of 'hits' in for-each

I have the code below. I would the for-each to stop running after the if-sentenses have returned true and executed the code block 4 times. As i have no idea when the code block has been executed 4 times i can't use position() which was my first idea. Any help would be greatly appreciated. <xsl:for-each select="$itm//item[@template='new...

if defined in XSLT

How I can check defined variable $var01 or not? The problem there are: <input type="text" name="search_do" style="width: 150px;" value="{$search_do}" /> But it isn't work, I have a message "runtime error" if $search_do isn't defined. P.S. I can't edit php back-end, just XSL template ...

XSLT: distinct values

I have XML like this: <items> <item> <products> <product>laptop</product> <product>charger</product> </products> </item> <item> <products> <product>laptop</product> <product>headphones</product> </products> </item> </items> I want it to output like laptop charger headphones I was...

Any way to have a generated counter value in XSLT?

IS there any way to use XSLT to generate unique IDs (sequential is fine) when they don't already exist? I have the following: <xsl:template match="Foo"> <xsl:variable name="varName"> <xsl:call-template name="getVarName"> <xsl:with-param name="name" select="@name"/> </xsl:call-template> </xsl:variable> <xsl:...