xslt

Problem using ancestor axis in an XPath predicate

Using this source document: <?xml version="1.0" encoding="UTF-8"?> <Root> <Element1 id="UniqueId1"> <SubElement1/> <SubElement2> <LeafElement1/> <LeafElement1/> </SubElement2> </Element1> <Element2 id="UniqueId2" AttributeToCheck="true"> <SubElement1> <LeafElement1/> <LeafElement1/> </Su...

problem using the xsl method for-each

Using XSL I am trying to turn this XML: <book><title>This is a <b>great</b> book</title></book> into this XML: <book>This is a <bold>great</bold> book</book> using this xsl: <xsl:for-each select="book/title/*"> <xsl:choose> <xsl:when test="name() = 'b'"> <bold> <xsl:value-of select="text()"/> </bold> </xsl:...

How to create XSLT transformation for srcML?

I have a question about XSL transformation. Lets take an example (in srcML) which represents a typedef enum in C: <typedef>typedef <type><enum>enum <name>SomeEnum</name> <block>{ <expr><name>Value0</name> = 0</expr>, <expr><name>Value1</name> = <name>SOMECONST</name></expr>, <expr><name>Value2</name> = <name>SOMECONST</name> + 1</exp...

Dot '.' in XML-Tags / Transforming w. XSLT

Hi, I've got an xml which shoule be transformed using XSLT but there are "." in the Tag and in cause of that it doesn't work. But the . is allowed in XML-Tags. Can anybody give me a hint on transforming such a file: XML: <root.element> <test.element>Hello World</test.element> </root.element> XSLT: <xsl:template match="/"> <tes...

Can I create a asp.net webform -or user control- output from an XML file by using XSLT?

Hi, Basically the thing I would like to achieve is to produce a form with some check boxes which will have their texts, default values from an xml file. As an example the block below should result 3 checkboxes (Use Sword, Use Shield, Use Spell) with the default values assigned. And when that form is posted back I can read them on the co...

How to use xslt to add namespaces to xml

I have a SOAP web service that is defined contract-first--the request and response xml are defined by xsds that use a number of different namespaces, and there are 100s of elements defined in xsds. However the web service calls a legacy layer which does not use namespaces in the xml. Therefore I have a transformation layer between the we...

XSLT Variables and Choose/Otherwise not working right..

I have some XSLT that looks like: <xsl:choose> <xsl:when test="string(//User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"> <xsl:variable name="Type" select="concat('Documenter', //User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"/> </xsl:when> <xsl:otherwise> ...

[XPath] Get the path of an element

Hi folks, is there a XPath function, which returns the absolute path of an element, so I can use it in sth. like: <xsl:if test="path() = /root/parent/child"> ... </xsl:if> Thanks. ...

Deleting xml nodes using xslt

Hello, Does anyone know how to copy only the first n nodes in a xml file and delete the rest using xslt? So say I only want to copy the first 10 nodes and delete the rest of the nodes that belong to the same parent. Thanks in advance! ...

Optimising XDocument to XDocument XSLT

The following code works but is messy and slow. I am transforming an XDocument to another XDocument using XSLT2 with Saxon, adapted using SaxonWrapper: public static XDocument HSRTransform(XDocument source) { System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream xslfile = thisEx...

XSLT: pass value from one for-each match to the next

I'm using the following to match all <section>s with a revision attribute set. <section>can appear at many different levels of the document tree, always contained within <chapter>s. <xsl:for-each select="//section[@revision]"> <!-- Do one thing if this is the first section matched in this chapter --> <!-- Do somethi...

Xml to Xml - Xslt

I am trying to learn xslt but have no good tutorials where i can find all info together please help me here... <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:attribute namespace="{namespace-uri()}" name="{name()}"/>...

Replacing URL Strings in an XML Document with XSLT

Hi, I am having trouble using the XSLT 1.0 function library (since .NET/Visual Studio doesn't support 2.0), replacing attribute strings using XSLT in my XML document. The attributes contain URL strings, but as soon as the URLs are read in via the translate() function, everything is garbled and comes out a mess. This is most likely due...

How do I pass a parameter from ASP to XSL?

I'm writing a simple asp page to show a team rota based on some XML. Here's the XML: <rota> <shift date="20091201" primary="Chan" secondary="John" notes="notes"></shift> <shift date="20091202" primary="Mike" secondary="Alex" notes="notes"></shift> <shift date="20091203" primary="Ross" secondary="Mike" notes="notes"></shift> <shift date=...

How do you access an element by its attribute value using XSL transforms and XML?

Hello All Im trying to transform an XML document into XHTML using XSL transformation and was wondering how i can choose an XML element given the value of its attribute. e.g. <image size="small">http:example.small.jpg</image> <image size="medium">http:example.medium.jpg</image> <image size="large">http:example.largw.jpg</image> I only...

EXSLT func:return problems in xsl:for-each "loop" and func:function

My problem: I have a wealth of atom RSS feed files which have many different atom entries in them and a few overlapping entries between files. I need to find and return an entry based on a URL from any one of the RSS feeds. Technologies: This code is being run through PHP 5.2.10's XLSTProcessor extension, which uses XSLT 1, has support ...

XSLT & Xpath syntax > how to refer to an element in an 'outer' scope

Hi, I have the following working 100% correctly. However to satisfy my curiosity... is there a way to achieve the same without declaring the currentID variable? Is there some way to reference it from within the Xpath "test" condition? The xpath query in the condition must refer to 2 @id attributes to see if they match. the 'current...

How to eliminate xmlns="" entries produced by XSLT transform of one XML doc to another XML doc.

Ok, I've seen numerous variations on this question, but none exactly answer what I'm trying to solve and perhaps I'm just too dense to see how to apply one of the other answers to what I'm trying to do. I have some XML that looks something like the following: <?xml version="1.0" encoding="utf-8"?> <message> <cmd id="api_info"> <a...

[C#]Add XSL reference in XMLDocument

Hi, I am creating an XML document from my C# code. I need to add the XSL reference in my XML document. My code is: XmlDocument xDoc = new XmlDocument(); if (!File.Exists(fileName)) { XmlDeclaration dec = xDoc.CreateXmlDeclaration("1.0", "UTF-8", null); xDoc.AppendChild(dec); **[Need to add code to add the XSL reference e.g....

Sum diff problem/bug in XSLT 1.0

I have this XML data and try and make a sum of it using the XSLT snippet below. Xml <?xml version="1.0" encoding="utf-8"?> <values> <value>159.14</value> <value>-2572.50</value> <value>-2572.50</value> <value>2572.50</value> <value>2572.50</value> <value>-159.14</value> </values> Xslt <?xml version="1.0" en...