xslt

Retrieve page URL params or page URL in XSLT

I have a page which has URL structure : http://www.abc.com/xyz?parama=1&paramb=2 Is is possible to create a generic method for getting the values of any additional params the URL maybe (parama=1&paramb=2) Is is possible to get the URL of the page in XSL similar to javascript's location.href ? ...

Creating conditional comments with XSLT ?

I want to create conditional comments in XSLT. But when I use this: <!-- [If IE7] [endif] --> in an <xsl:comment>, XSLT removes it from the output when it is rendered. Is there any way to create conditional comments in XSLT? ...

Dom4j rule does not match all expected nodes

I'm using dom4j's rules api to fire an action if the predefined pattern //authorize matches an element in the following xml snippet. <authorize role_required="admin"> <node title="node which is visible only to admin" path="" > <authorize role_required="admin"> <node title="node which is visible only to admin" path=""/> ...

XSLT : transform only the specified elements

Hi everyone, I am trying to develop an XSLT stylesheet which will transform an xml into another by keeping in view: By default the stylesheet should display nothing for each element (not even the text). If there is an explicit template match for an element, then copy that element, it's attributes and all its sub-elements (and their at...

My PHP app needs to export to a range of different XML formats: should I use XSLT or native PHP?

My PHP application will need to be able to export to (and import from) a range of different data formats, mostly XML based. I have the option of In PHP, use DOM to export to some XML based format that is a superset of all the data needed by the others, and create a separate XSLT stylesheet for each output format I want to support, run...

How to add xsl stylesheet node to XML produced by XmlSerializer?

I have an WCF REST service which returns objects serialized with XmlSerializer. How can I add XSL stylesheet information (like the one below) to the output returned by the WCF service? <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="transforms/Customer.xsl"?> <Customer> <Name>Foo</Name> </Customer> My...

Recursively reading an xml document and using regex to get contents

I have an xml document like the following: <menuitem navigateurl="/PressCentre/" text="&#1087;&#1088;&#1077;&#1089; &#1094;&#1077;&#1085;&#1090;&#1098;&#1088;"> <menuitem navigateurl="/PressCentre/RegisterForPressAlerts/" text="&#1088;&#1077;&#1075;&#1080;&#1089;&#1090;&#1098;&#1088; &#1079;&#1072; &#1087;&#1088;&#1077;&#1089; &#...

xslt concat with select inside for-each

Can i use a Select within a concat in xslt? eg <xsl:for-each select="root/OrderItems/lineitem"> <xsl:element name="img"> <xsl:attribute name="src"> <xsl:value-of select="concat('http://www.site.com/r&amp;amp;h=11', '&amp;q=',<xsl:value-of select="Quantity" />, )" /> </xsl:attribute> </xsl:element> </xsl:for-each> ...

Condition works for XSLT 1.0 stylesheet, but not for XSLT 2.0 stylesheet

Consider this condition that exists in a template that is called recursively: <xsl:if test="$i &lt;= $count"> I'm using an XSLT 2.0 processor (Saxon-B 9.1.0.6). The condition seems to work only when running an XSLT 1.0 stylesheet. When the stylesheet version is set to 2.0 (as it should be), it stops working. Any ideas why? Here's th...

xslt check if string is null or empty

how chan i check if a value is null or empty with xsl? eg if categoryName is empty? im using a when choose construct eg: <xsl:choose> <xsl:when test="categoryName !=null"> <xsl:value-of select="categoryName " /> </xsl:when> <xsl:otherwise> <xsl:value-of select="other" /> </xsl:otherwise> </xsl:c...

How can I prevent these redundant namespaces from an XSLT stylesheet?

When using an XSLT stylesheet to transform an XML file which contains embedded XHTML (using namespaces) into pure XHTML, I'm left with redundant namespace definitions on the elements which were originally XHTML. Simple test case: XML: <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xml" href="fbb.xsl"?> <foo xmlns=...

Optional parameters when calling an XSL template

Is there way to call an XSL template with optional parameters? For example: <xsl:call-template name="test"> <xsl:with-param name="foo" select="'fooValue'" /> <xsl:with-param name="bar" select="'barValue'" /> </xsl:call-template> And the resulting template definition: <xsl:template name="foo"> <xsl:param name="foo" select="$foo...

XSL Transform Across Namespaces

I have XML that looks something like this: <Root xmlns="http://widgetspecA.com/ns"&gt; ...any... <WidgetBox> <A/> <B/> <SmallWidget> <!-- minOccurs='0' --> ...any... </SmallWidget> <Widgets> <!-- minOccurs='0' --> ...any... </Widgets> ...any... </WidgetBox> ...any... </Root> and I want t...

What is the current state of XSLT 2.0 availability within .NET

The latest I can find from the web and blogosphere indicate that Microsoft's XML team would be supporting XSLT 2.0 (now that it was a full blown W3C recommendation). I can't find anything beyond that. What's the current status? Is it available in .NET 3.5 or are they stuck with XSLT 1.1 and pushing XQUERY and LINQ? ...

XSLT character encoding problem

Hey guys, I'm using XSLT and having great success, just got a couple of problems. Warning: DOMDocument::loadXML() [domdocument.loadxml]: Entity 'Aring' not defined in Entity Basically for some non-standard characters I am getting the above type of error. I really want to fix this once and for all. I know about character mapping but I ...

Exception when serializing WPF contols

I have an Application (an appointment manager) which lets the user create usercontrols in a stackpanel per button click and the user can enter data into the usercontrols. So far so good. I serialized the stackpanel with XamlWriter.Save(). But then when I try to load it again the next time the application starts with XamlReader.Load() I ...

In XSLT how do I increment a global variable from a different scope?

I am processing an XML file where I want to keep count of the number of nodes, so that I can use it as an ID as I write new nodes. At the moment I have a global variable called 'counter'. I am able to access it within a template, but I haven't found a way of manipulating it within a template. Here is a condensed version of my XSLT file...

XSLT and Line Feeds

I am using XSLT to reformat some XML, to (a) turn elements into attributes and (b) sort everything alphabetically. It works EXCEPT the attributes are all on one line. I understand this is usually preferable but in this case I need each attribute to appear on a separate line when I open the file in Notepad++ (or whatever). I can add XML-...

.NET Windows control for editing XML/XSL?

Apologies if this has been asked before. Had a quick search and there's nothing that answers my question 100%. I've got some XSL stored in the database which I want the user to be able to edit within my .NET Windows application. I could just stick it into a multi-line textbox but then I don't get anything like auto-indent, colour-coding...

Client-side XSLT

I converted my whole site to XML/XSL and I would like to know all of the current issues with performing Client-side XSLT. Here are the ones i already know of (from first-hand experience): Cross-domain XSL files (this is a security issue and not cross browser) disable-output-escaping (this does not work in FF... they consider it a secu...