|
Hi,
I want to declare a variable or param at the top of my XSL file then I want to assign its value inside <for:each> loop and in the end I want to use its value outside the loop may be template as well. I tried my best but could not fix. anyone of you knows about it? Please send me sample code.
Greetings,
Abubakar
|
|
|
|
|
XSL variables don't work like those in a normal programming language. You can't increment inside a loop for example. The way around this is to use recursion and pass the final result up the stack. When it all completes your variable is then populated with the final result. But from that point on it's static.
<xsl:template match="/">
<xsl:variable name="myVariable">
<xsl:call-template name="forLoop">
<xsl:with-param name="counter" select="10" />
</xsl:call-template>
</xsl:variable>
</xsl:template>
<xsl:template name="forLoop">
<xsl:param name="counter" />
<xsl:choose>
<xsl:when test="$counter!=0">
<!-- do some work -->
<xsl:variable name="stackResult">
<xsl:call-template name="forLoop">
<xsl:with-param name="counter" select="$counter-1" />
</xsl:call-template>
</xsl:variable>
<!-- do something with the result of the recursion "$stackResult" -->
<!-- return a result up the stack -->
<xsl:value-of select="new value" />
</xsl:when>
<xsl:otherwise>
<!-- return something to indicate you've reached the base case w/in the recursion -->
<xsl:value-of select="some value" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
|
|
|
|
|
Hi,
I don't want to increment in the value of param or variable. I just want to check in >for:each< loop that if records exists then make param value 'true' otherwise set it false. I just wanna do this and later want to use its value outside the loop may be template as well. I tried my best but could not fix. anyone of you knows about it? Please send me sample code.
Greetings,
Abubakar
|
|
|
|
|
Can you post an xml fragment and a snippet of what it is you're trying to do? Then it would be easier to provide you with an answer that suits your needs.
|
|
|
|
|
I am getting values from webservice and using xsl file to format it. hereby I am sending u xsl file code. I just want that
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="ID"></xsl:param>
<xsl:param name="searchString"></xsl:param>
<xsl:template match="Category">
<xsl:for-each select="./Clip">
<xsl:choose>
<xsl:when test="Title = $searchString or ./MetaData/ArticleName = $searchString">
<!-- Set value of a param to 'true' which means record Found -->
</xsl:when>
<xsl:otherwise>
<!-- Set value of a param to 'false' which means record not Found -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<!--Make a check here whether record found or not -->
<xsl:if test="$paramName='true'">
// do something
</xsl:if>
<xsl:if test="$paramName!='true'">
// do something else
</xsl:if>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
Try this, it should return true or false:
<xsl:variable name="paramName" select="Clip[Title=$searchString] or Clip/MetaData[ArticleName=$serachString]" />
Then you should be able to use the value like in your example above.
|
|
|
|
|
i ma usin gthe extension object in XSLT and then passing a string to XSLT like this
for(int i=0;i<xmlnode.count;i++)
{
xmlattributecollection="" xmlattrc="xmlnode[i].Attributes;
"
="" all="" +="<br>" ;
=""
}
return="" all;
and="" then="" using="" it="" in="" xslt="" like="" this
<xsl:value-of="" select="RDisc:GetAllData()">
but is showing data in one line also included the how i can solve this. I have also tried as
all +=<br>
I love .NET
|
|
|
|
|
i am fetching some data from SQL and filling it through the Adapterto in DataSet, and then passing that DataSet to the XmlDataDocument Object, like
XmlDataDocument XMLDoc = new XmlDataDocument(dsOrders);
and then again i take SqlDataAdapteradapter2 with new Query and again fill the same Dataset. means there are now two results, resulted by 2 queries
XMLDoc.DataSet.EnforceConstraints = false;
and then i am accessing that data through XSLT and exporting it as Excel,
when i access the data of the First query in XSLT it shows the required result but it also repeat the rows for the seocnd result,
like suppose there are total 7 rows in out put 3 are for first query and 4 are for 2nd query and i need the print only first 3 [of first query] but it displays thw hwole 7, first 3 showing results but last 4 with no values.
why it is repeating.
I love .NET
|
|
|
|
|
Hi All,
Which option is good to use to increase the perfomance in xslt programming.
For-each
or
apply templates
Can any body guide me giving some tips of perfomance tuning in xslt.
Pls show me the right way...
Thanks,
RPM.
SoftwareDeveloper(.NET)
|
|
|
|
|
The XSL Elements, xsl:for-each and xsl:apply-templates, performance is not that important in my honest opinion. I use xsl:for-each for simple processing requirements, and xsl:apply-templates for more demanding functional processing. Overuse of xsl:for-each will complicate your code and make it harder to debug. Also, there are some things you cannot do with xsl:for-each but you can do with xsl:apply-templates.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Does anyone know where I can obtain a copy of the MSXML 5.0 SDK?
|
|
|
|
|
As far as I know, MSXML 5 is not available for download.
MSXML 6 SDK is available:
http://www.microsoft.com/downloads/details.aspx?FamilyID=993c0bcf-3bcf-4009-be21-27e85e1857b1&DisplayLang=en
-------------------------
Don't worry, be happy )
|
|
|
|
|
Thanks for your reply. But according to MS's web site MSXML 6.0 does not cater for digitally signing an XML document which is what I need to be able to do.
I need to:
(1) Perform a C14N transform on the part of an XML doc.
(2) Produce a Sha1 digest of the result from (1) above.
(3) Convert the result from (2) above into a Base64 string.
If anyone knows how to do this using MSXML 6.0 I would be very interested to hear. Otherwise, I need to know how to get hold of MSXML 5.0. Was MSXML 5.0 on any of the MSDN disks?
|
|
|
|
|
Maybe the classes inside the System.Security.Cryptography.Xml namespace can help you. For example, there is a XmlDsigC14NTransform that is probably what you're looking for.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks for that information on the .NET namespace, with all respect I was already aware of that namespace, but I am not using .NET and cannot in the application for which I am writing. I am presently investigating the Apache library.
|
|
|
|
|
guys i am selecting some data from SQL database and then handling it in XML and then exporting it into Excel file. i did it. but then again i included a new XML document in XSLT using
<xsl:variable name="ed" select="document('stu.xml')/data/room">
and when i again run the code it does not select anything from "stu.xml" means from second document. but when i make a new application andpaste the same code over there then it runs fine why it is not running with the previous code.
I love .NET
|
|
|
|
|
how can i pass an array as an argument in xslt.
I love .NET
|
|
|
|
|
We test a particular constriant in our XSLT and throw a custom exception on failure:
<xsl:when test="......">
<xsl:value-of
select="exception:throwException('Recording failed')">
Here exception is defined as:
xmlns:exception="http://..../util.exception.ValidationExceptionThrower"
The problem is that this kind of exception handling by-passes the java code.
In our Java client,we have the following:
{
.........
TransformerFactory tFactory = TransformerFactory.newInstance();
transformer = tFactory.newTransformer(source);
....
StreamResult result = new StreamResult();
java.io.ByteArrayOutputStream outputXmlResult = new
java.io.ByteArrayOutputStream();
result.setOutputStream(outputXmlResult);
transformer.transform(xmlsource, result);
setOutXml(outputXmlResult.toString());
return "Success";
}
catch(ValidationException ex) {
System.out.println("INSIDE VALIDATIONEXCEPTION");
......
}
finally {
return "failure";
}
}
The exception thrown by XSLT does not get trapped by the error handler in the client.
How can XSLT be adapted to throw a 'catchable' exception.
|
|
|
|
|
Trying to read xml file into html table.
pretty simple stuff. I got an example off the net to work BUT only in IE, I would like it to work atleast in a few browsers rather than just one being IE.
I tried:
opera
netscape
firefox
but didnt display xml data.
Can anyone see if the code should be changed or have any suggestions to do this simple task
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><br />
<title>Markets</title><br />
<br />
</head><br />
<br />
<body><br />
<br><br />
<xml id="Markets" src="markets.xml"></xml><br />
<br />
<table border="1" datasrc="#Markets"><br />
<br />
<thead><br />
<tr><th>Name</th><br />
<th>Location</th><br />
<th>Date</th><br />
</tr><br />
</thead><br />
<br />
<tbody><br />
<tr><br />
<td><span datafld="name"></span></td><br />
<td><span datafld="Location"></span></td><br />
<td><span datafld="date"></span></td><br />
</tr><br />
</tbody><br />
</table><br />
<br />
</body><br />
</html><br />
<br />
|
|
|
|
|
Take a look at this: XML Application[^] The note at the beginning clearly states that a data island (the xml tag) only works in Internet Explorer.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
can anyone suggest a cross browser compatible code then ?
surely this is a task that has been done many times ?
thanks anyway Stefan
|
|
|
|
|
I think the safest way regarding browser compatibility is to use XSL/XSLT to transform the XML document into a plain XHTML document without any fancy browser specific stuff.
A good starting point for reading is this XSLT Tutorial[^]. Besides this, I'm quite sure the internet is full of more resources. Simply google for the involved technologies.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
thanks for your assistance stefan
|
|
|
|
|
I am looking for either a schema or non-3rd party parser to convert a doc,txt, or rtf to xml.
Thank you in advance.
Any help would be greatly appreciated.
|
|
|
|
|