xslt

xpath xsl find when parent have attribute equal to value

These is my xml: <root> <node> <element id='1'> <subelement>val</subelement> </element> <element id='2'> <subelement>val</subelement> </element> </node> i don't know the parent name and 'node' name The solution descendant::*[ @id= '1' ]/subelement ...

Xml Traversing with javascript

<links> <osname name="windows xp" links="xyz" /> <osname name="windows 2k" links="xyz" /> </links> <owners name="microsoft"> <os name="windows xp" /> <os name="windows 2k" /> <os name="windows 2003" /> <os name="windows 7" /> </owners> <owners name="microsoft"> <os name="windows xp" /> <os name="windows 95...

Writing XML with a simple HTML form

Is there a way to use the value from the form into XML nodes? Once they submit this form I want the values from the form fields to overwrite the existing nodes. <html> <head></head> <body> <form id="myForm" method="POST"> <input type="text" value="new XML node value here" /> <input type="submit" onClick="function();"/> </form> <...

Remove XML node when child node meets certain requirements

Hello all I have the following xml: <listaGiros> <giro> <idGiro type="int">89</idGiro> <nombreGiro type="varchar">foo</nombreGiro> </giro> <giro> <idGiro type="int">78</idGiro> <nombreGiro type="varchar">apple</nombreGiro> </giro> <giro> <idGiro type="int">10</idGiro> ...

Substituting values over many XML elements [XSLT 2.0]

Hello everybody, This question is an extension of this one. I have many values, as seen below: <myStuff> <elem1>asdf</elem1> <elem2>foo bar</elem2> <elem3>foo bar foo</elem3> <elem4>foofoo</elem4> </myStuff> I've been doing a copy-of over MOST the elems (the select in the copy-of is very specific) and then doing a fin...

Trigger a function call on clicking a link, returning the link value that's clicked.

Basically, I'm looking to get 'URLValue' if the particular <a> is clicked and pass it on to another method. There are several other <a> elements with class="LinkClass" and I have written a JQuery to get only the clicked element value. Below is a working JQuery to do just this, it references the XSL. $("a.LinkClass").live("click", func...

How to specify a sortBy through a javax.xml.transform.Transformer.transform() call?

I'm using javax.xml.transform.Transformer.transform() to convert one xml to another through an xsl stylesheet. I would like to programatically set the sorting of the first level of children, but am unsure how to go about it. I've checked out the docs, but I don't understand which type of property/parameter to use and how to specify in so...

XSLT for-each question

I have an xml <Root> <Parent> <Child1>A</Child1> <Child2>B</Child2> <Child1>X</Child1> <Child2>Y</Child2> </Parent> </Root> Child2 always will be with child1. I need to know how I can loop through using xsl:foreach and create an XML output example. <TransformedXML> <Child attribute1="A" attribute2="B"/> <Chil...

xslt grouping question

I have an xml <Root> <Parent> <Child1><Node1>AAA</Node1><Node2>BBB</Node2></Child1> <Child2><NodeX>XXX</NodeX><NodeY>YYY</NodeY></Child2> <Child1><Node1>EEE</Node1><Node2>FFF</Node2></Child1> <Child2><NodeX>GGG</NodeX><NodeY>HHH</NodeY></Child2> <OtherChild></OtherChild> </Parent> </Root> Child2 always will b...

Referencing inserted elements in a single pass

I'm trying to insert unique IDs and references to those IDs using a single XSLT file. Given the XML: <Parent> <Name>Dr Evil</Name> <Child> <Name>Scott Evil</Name> </Child> </Parent> And this XSLT snippet after an identity transform: <xsl:template match="Parent"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:...

Xslt generating Html <IMG> tags. How to use an XML node value as an src-attribute for the <IMG> Tags.

Hi I'm still searching, but I haven't found yet the way to perform something like this: xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <!-- some other templates --> <xsl:template match="IMAGE"> <img src="src_attribute_to_be_read_from_the_xml_file.jpg"/> </xsl:template> </xsl:s...

XSLT : Creating a Map in XSLT

Hi, I want to have a key value map in xsl and so defined a variable which has an xml fragment, but later when i try to access the xml nodes in the variable i get an error that type of the xpath xpression cannot be resolved. Below is the xsl- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <xsl:template...

How to pass js var in xslt

Hi All, I have a javascript variable something like: var str = "AA,BB,CC,AA,BB,DD"; var totlength = str.split(",").length; var xx = str.split(","); for (var i = 0; i < totlength; i++) { alert(xx[i]); } and I could print this value using above method.Now the problem is I have to craete on...

ANT ANTForm XSL - Cheat Sheet

Hi folks, In another question - http://stackoverflow.com/questions/3530181/getting-directory-listing-from-svn-for-use-in-ant-dropdown/3546043#3546043 I asked about how I can connect SVN up to my ANT scripts directly. The answer I got was really good and follows the lines of exporting a directory listing from SVN as XML and then using X...

Can I include *.xslt in ASP.NET class library for internal use?

I want to use same xsl template in few websites. Can I add it into class library? If yes how can I Load it? Example of path, etc... ...

XSLT and XPATH: Not able to Read Certain Attributes

<field type="math" size="12" unitText="%" unitPos="back"/> I am able to select "type" and "12" from their respective fields but I cannot do the same for unitText and unitPos. Any ideas why? Below is what I'm using to print type and size. <xsl:value-of select="@size"/> I am entering the "field" tag with this line <xsl:template mat...

Move certain child nodes down to a new grandchild level

Hi. I've found other questions on moving nodes upwards into the parent but I'm missing the trick to move them down into a newly created node. Given: <Villain> <Name>Dr Evil</Name> <Age>49</Age> <Like>Money</Like> <Like>Sharks</Like> <Like>Lasers</Like> </Villain> I'm trying to transform this with XSLT to: <Villain> <Nam...

C++ XLST tranform not working using MSXML 3.0

Hi guys, I'm new to C++ and inherited the following code that is supposed to transform the given XML using the XSLT file to just spit out the text values. It loads both the XML and XSLT fine and the transformnode() call returns success but no transformation has been applied. The original output at the bottom contains the original XML i...

Merge two XML streams using XSLT matching on key values

Hello, I'm new to XSLT and I would like to know how to merge 2 XML streams before finally transforming it again. The 2 streams are Input 1 <Response> <Instrument> <Date value="2010-09-02"> <Quantity>10</Quantity> </Date> <DXLID>1</DXLID> </Instrument> <Instrument TICKER="APPL" /> <...

How can I remove whitespace from my xsl variable?

I have to create an xsl variable with a choose in it. Like the following: <xsl:variable name="grid_position"> <xsl:choose> <xsl:when test="count(/Element) &gt;= 1"> inside </xsl:when> <xsl:otherwise> outside </xsl:otherwise> </xsl:choose> </xsl:variable> And later in my code, I do an xsl if: <xsl:if te...