|
We use XSLT to convert various XML files into tab delimited.
Some of the XML input files have a variable number of options. Sometimes none, others 1,2,3 or more.
This makes the formatting difficult since there is also a header row that is created in the XSLT file that must have the exact number of columns and proper header context.
So the question is how to get this formatted correctly since if we provide for 2 sets of opts (from the W3Schools tryit) in the header row how to get the for-each to stop at 2.
<cd>
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
<cd>
<opts length="3">
<opt><name>Nm1</name><val>111</val></opt>
<opt><name>Nm2</name><val>222</val></opt>
<opt><name>Nm3</name><val>333</val></opt>
</opts>
Typical for-each
<xsl:for-each select="opts/opt">
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="val"/></td>
</xsl:for-each>
In this case there will be 3 sets of opts but 2 sets of headers and all data after this will be off.
Tried using xls:when test="@length =...' but don't see a way of just getting 2 of the 3 opts.
Can anyone help?
Thanks
|
|
|
|
|
|
Thanks
Yes, using the Position() function did help but part 2 of this was still a lot more code that had to be added to complete what I needed to and I do not like it.
<b>How do we code for the mininum number of iternations when the input XML has less than the minimum?</b>
The Position did limit the output to the number of iterations we needed to see but it did nothing to fill in if the number of iterations was LESS that what we expected.
In our case the input XML had a length attribute.
<pre lang="xml">
<Opt length="1"><Opts>data</Opts></Opt></pre>
So we had to add a bunch of if or choose statements
<xls:if test="@length = "1">
...fill put in 4 output empty values
</xls:if>
<xls:if test="@length = "2">
...fill put in 3 output empty values
</xls:if>
Is there a better way?
-- modified 17-Dec-12 6:52am.
|
|
|
|
|
Hi,
I haven't done anything like this before but I did a quick bit of hunting around and something like this might do it for you. Please note this is totally untested and is just an idea. I thought about how to do a while or a normal for loop in XSL and then try and find away of checking if the <opt> element at position x existed. This is cobbled together from a couple of SO posts and my own take on how to put it together.
Sources:
http://stackoverflow.com/questions/11127693/how-to-do-a-while-like-loop-in-xslt[^]
http://stackoverflow.com/questions/5791053/xslt-if-tag-exists-apply-template-if-not-choose-static-value[^]
http://www.sourceware.org/ml/xsl-list/2000-08/msg01503.html[^]
From those articles this is what I have cobbled together:
<xsl:template name="for_loop">
<xsl:param name="num">1</xsl:param>
<xsl:param name="limit"></xsl:param>
<xsl:if test="not($num = $limit)">
<xsl:choose>
<xsl:when test="not(opt[position() = $num)">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="for_loop">
<xsl:with-param name="num">
<xsl:value-of select="$num + 1">
</xsl:with-param>
<xsl:with-param name="limit">
<xsl:value-of select="$limit">
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
Hope this helps.
Chris
|
|
|
|
|
Yes, I started to look at params and variables but with the complexity of the multiple templates I just could not get it to work. The XSLT is too big as it is and it was hard to put it all together.
I will have to re-look at it and perhaps test with a small XSLT until I can get the multi-templates and for loop template to work.
Thanks!
|
|
|
|
|
 Hi,
not sure if this is any help, I have used this to produce a student timetable grid. It does not do anything fancy at all, but it does use params and nested templates. It's quite old now and i'm sure it could be improved no end but it works well and might be of interest.
Chris
="1.0"="UTF-8"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:if test="pupil/details[count(.) != 0]">
<h1>Week A</h1>
<table class="ec-gridview" width="100%">
<xsl:apply-templates select="pupil/details [@weekCode='A'][1]" mode="weekheader"/>
<xsl:apply-templates select="pupil/details [@weekCode='A'][1]" mode="weekdata">
<xsl:with-param name="week">A</xsl:with-param>
</xsl:apply-templates>
</table>
<xsl:apply-templates select="pupil/details [@weekCode='A'][1]" mode="ott">
<xsl:with-param name="week">A</xsl:with-param>
</xsl:apply-templates>
<br/>
<h1>Week B</h1>
<table class="ec-gridview" width="100%">
<xsl:apply-templates select="pupil/details [@weekCode='B'][1]" mode="weekheader"/>
<xsl:apply-templates select="pupil/details [@weekCode='B'][1]" mode="weekdata">
<xsl:with-param name="week">B</xsl:with-param>
</xsl:apply-templates>
</table>
<xsl:apply-templates select="pupil/details [@weekCode='B'][1]" mode="ott">
<xsl:with-param name="week">B</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="details" mode="weekheader">
<tr class="ec-gridrow-header">
<th class="ec-gridheader" scope="col" style="width:5%;text-align:center"></th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Mon</th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Tue</th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Wed</th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Thu</th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Fri</th>
<th class="ec-gridheader" scope="col" style="width:16%;text-align:center">Sat</th>
</tr>
</xsl:template>
<xsl:template match="details" mode="weekdata">
<xsl:param name="week"/>
<tr class="ec-odd-line">
<td class="ms-vb" style="vertical-align:text-top;text-align:center">
1
</td>
<xsl:apply-templates select="//details[@lessonNumber='1' and @weekCode=$week]" mode="p1-6"/>
</tr>
<tr class="ec-even-line">
<td class="ms-vb" style="vertical-align:text-top;text-align:center">
2
</td>
<xsl:apply-templates select="//details[@lessonNumber='2' and @weekCode=$week]" mode="p1-6"/>
</tr>
</xsl:template>
<xsl:template match="details" mode="ott">
<xsl:param name="week"/>
<xsl:if test="count(//details [@lessonNumber > 299 and @weekCode=$week]) != 0">
<h1 class="ms-rteCustom-ArticleHeadLine">Lessons not on the timetable</h1>
<xsl:for-each select="//details [@lessonNumber > 299 and @weekCode=$week]">
<a>
<xsl:attribute name="href">
../Information/Set/SetLists.aspx?IsetCode=<xsl:value-of select="@setCode"/>
</xsl:attribute>
<xsl:value-of select="@setCode"/>
</a> (<xsl:value-of select="@subjectName"/>) <xsl:value-of select="@description"/><br/>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template match="details" mode="p1-6">
<xsl:for-each select=".">
<td style="vertical-align:text-top;text-align:center;min-height:60px;">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@currentLesson = 'Y'">ms-vb-cp</xsl:when>
<xsl:when test="@setCode = 'BLANK'">
<xsl:choose>
<xsl:when test ="@dayIndex = '1' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '2' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '3' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '4' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '5' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '6' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '8' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '9' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '10' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '11' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '12' and @lessonNumber = '6'">ms-vb-empty</xsl:when>
<xsl:when test ="@dayIndex = '13' and (@lessonNumber = '5' or @lessonNumber = '6')">ms-vb-empty</xsl:when>
<xsl:otherwise>ms-vb</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>ms-vb</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="@setCode != 'BLANK'">
<xsl:value-of select="@subjectName"/>
<br/>
<a>
<xsl:attribute name="href">
../Information/Set/SetLists.aspx?IsetCode=<xsl:value-of select="@setCode"/>
</xsl:attribute>
<xsl:value-of select="@setCode"/>
</a>
<br/>
<a>
<xsl:attribute name="href">
../Information/Room/RoomDetails.aspx?IroomCode=<xsl:value-of select="@room"/>
</xsl:attribute>
Room <xsl:value-of select="@room"/>
</a>
<br/>
<xsl:for-each select="teacher">
<xsl:value-of select="@teacher"/>
<br/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:text xml:space="preserve"> </xsl:text>
<br/>
<xsl:text xml:space="preserve"> </xsl:text>
<br/>
<xsl:text xml:space="preserve"> </xsl:text>
<br/>
<xsl:text xml:space="preserve"> </xsl:text>
<br/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
Hello, how do I design a pop up menu just like the one on www.list-of-companies.org when you click the country dropdown link.
I would actually prefer a solution that categorizes the link.
Thank you. 
|
|
|
|
|
From my experience this site is more for answering questions when you may encounter problems while you are doing the coding. You could probably find finished products at sites such as This or at sites such as here.
vbmike
|
|
|
|
|
http://jqueryui.com/[^] has lots of nice features. I would just google for jquery plugins that you want and find one that looks like it does what you want.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I've some data, there are
RealData Balance Sort by Desc
A 684 345 A 684
B 60 - E 308
C - - J 302
D - - I 273
E 308 - O 178
F - - H 140
G 11 - B 60
H 140 - N 27
I 273 - Q 22
J 302 - R 20
K - - P 14
L - - G 11
M - - C -
N 27 - D -
O 178 38 F -
P 14 - K -
Q 22 - L -
R 20 4 M -
Description
Proc = Process
Res = Result
Sort by Desc
Get 8 row data
Proc 1 Res 1 Proc 2 Res 2 Proc 3 Res 3 Proc 4 Res 4 Finish for 8 row data
A 684 657 A 657 635 A 635 621 A 621 610 A 610
E 308 281 E 281 259 E 259 245 E 245 234 E 234
J 302 275 J 275 253 J 253 239 J 239 228 J 228
I 273 246 I 246 224 I 224 210 I 210 199 I 199
O 178 151 O 151 129 O 129 115 O 115 104 O 104
H 140 113 H 113 91 H 91 77 H 77 66 H 66
B 60 33 B 33 11 R 20 6 B 11 - R 6
N 27 - Q 22 - P 14 - G 11 - B -
Q 22 22 R 20 20 B 11 11 R 6 6 G -
R 20 20 P 14 14 G 11 11 P - - P -
P 14 14 G 11 11 Q - - Q - - Q -
G 11 11 N - - N - - N - - N -
C - - C - - C - - C - - C -
D - - D - - D - - D - - D -
F - - F - - F - - F - - F -
K - - K - - K - - K - - K -
L - - L - - L - - L - - L -
M - - M - - M - - M - - M -
Result 1 27
Result 2 22
Result 3 14
Result 4 11
Total 1 74 (For 8 row data)
Get 4 row data
Proc 1 Res 1 Proc 2 Res 2 Proc 3 Res 3 Finish for 4 row data
A 610 411 A 411 376 A 376 347 A 347 345
E 234 35 O 104 69 O 69 40 O 40 38
J 228 29 H 66 31 H 31 2 R 6 4
I 199 - E 35 - J 29 - H 2 -
O 104 104 J 29 29 R 6 6 J - -
H 66 66 R 6 6 E - - E - -
R 6 6 I - - I - - I - -
B - - B - - B - - B - -
G - - G - - G - - G - -
P - - P - - P - - P - -
Q - - Q - - Q - - Q - -
N - - N - - N - - N - -
C - - C - - C - - C - -
D - - D - - D - - D - -
F - - F - - F - - F - -
K - - K - - K - - K - -
L - - L - - L - - L - -
M - - M - - M - - M - -
Result 1 199
Result 2 35
Result 3 29
Result 4 2
Total 2 265 (For 4 row data)
How to get this data using Query or Function? And how to using in PHP?
Please help!
Thank you.
Jimmy
|
|
|
|
|
|
Can you advise me what web technologies must use for developing huge Web projects, what frameworks maybe? I want to see all picture elements the future developing system
Now i know only: PHP, CSS, HTML, JavaScript, Jquery, Codeigniter/
|
|
|
|
|
Some of the biggest web sites use PHP/MySQL, some use CodeIgniter as a MVC solution when developing PHP/MySQL solutions. Some use WordPress, which incidentally is PHP/MySQL.
Other websites use ASP.NET with some flavour of SQL Server.
Other solutions include JSP.
But a Google search can deliver to you much more information than I can in a single reply.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I have a gridview with a checkbox column, i select a checkbox in a row and click edit button after that, edit button click_event i wrote this:
grvWorkDetail.DataKeys[grvWorkDetail.SelectedIndex].Values["WorkTimeID"].ToString()
but it has error, and i cant access to "WorkTimeID"
my codebehind is :
<asp:TemplateField ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
<asp:CheckBox ID="chk_SelectAll" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk_Select" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center"
|
|
|
|
|
Please do not post the same question in multiple forums.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
how to upload (.flv)file using php
please help me
i try use $_files['file']['type']
but i have problem in this kind of extension only
thank you.
|
|
|
|
|
please help me i am wait for answer
|
|
|
|
|
move_uploaded_file($_FILES["fileAttach"]['tmp_name'], $orgFilename) - did you test it?
|
|
|
|
|
I Have Made Website
http://divyamsolanki.hpage.com
How To Create Our Own Design..Please Reply Me
-Divyam Solanki
|
|
|
|
|
Divyam. Your question is not clear to me. I have visit your site and found a welcome page having some link also, though the design is not so rich.
It seems to me that, you want to make your site rich by design, i.e., you need HTML template. If so, you may googling for HTML free templates and you will get numerous in count to modify that according your own interest.
Just go to GOOGLE and search by "free HTML template".
|
|
|
|
|
Hi I am developing a wcf service with netNamedpipesBinding when I run the service (debug->start new instance)I am getting the error as "the protocol 'net.pipe' is not supported"
web.config file as below.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="ServiceBehaviour"></behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<netNamedPipeBinding>
<binding name="ServiceBinding">
<security mode="None"></security>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service name="WcfNPService.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint name="NPEndPoint" address="net.pipe://localhost/WcfNPService/Service1.svc"
binding="netNamedPipeBinding"
contract="WcfNPService.IService1" bindingConfiguration="ServiceBinding"></endpoint>
</service>
</services>
</system.serviceModel>
</configuration>
|
|
|
|
|
I can only suggest that you check if "Net.Pipe Listener Adapter" service is running in Services management console.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Thanks Rechard,
I just started developing WCF Services,can we self host these service which are using named pipes binding?
Is this binding any way related to IIS version I have on the machine too(I have IIS 5.1 only)?
I read from Msdn saying(NamedPipe Activation require IIS 7.0).
so can't i use these bindings with IIS 5.1?
Regards,
Mallikharjun.
|
|
|
|
|
As far as I am aware, IIS5.1 is Windows XP and Windows XP does not support what you want to achieve. Your choice is to upgrade to an operating system that does support what you want to achieve.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Hi all.
when I using header('location:'.$url) then it redirect to url another, cannot get message from this url. how to when to get data when use header('location:'.$url) ???
thanks
nothing
|
|
|
|