473,543 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to repeat some set of steps using xslt, as we do using functions in C or C++?

9 New Member
Hi,

As part of migrating bugs from JIRA to BugZilla, below is the requirement:

If there are multiple “version” tags in my input.xml file
For open bugs (Resolved,Reope ned,Inprogress, NeedInfo) > create multiple bugs, one for each “version". “Fix version” will be empty.
For closed bugs > create multiple bugs, one for each “Fixed in” version. Use earliest “version" for all bugs.

I tried using the apply-template in the XSLT for the above requirement as shown below:

XSLT Code:

<xsl:if test="status = 'Open'">
<xsl:for-each select="/rss/channel/item/version">
<xsl:apply-templates select="/rss/channel/item">
<!--<xsl:with-param name="itemDetai ls" select="."/>-->
</xsl:apply-templates>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</bugzilla>
</xsl:template>
<xsl:template match="item">
<!--<xsl:param name="itemDetai ls"/>-->
<bug>
<version>
<xsl:value-of select="version " />
</version>
</bug>
</xsl:template>
</xsl:stylesheet>


XML Code:

<?xml version="1.0" encoding="UTF-8" ?>


<!-- RSS generated by JIRA 91 at Mon Sep 15 06:28:30 EDT 2008 -->

<rss version="0.92">
<channel>
<title>Sentin el Issue Tracking System</title>
<link>http://bugs.esecurity. net:8090</link>
<description>Th is file is an XML representation of an issue</description>
<language>en</language>
<item>
<title>[SEN-8448] CIDR-enabled dynamic lists</title>
<link>http://bugs.esecurity. net:8090/browse/SEN-8448</link>
<description> <![CDATA[L-3 (Partner) requested to store in the dynamic list, a representation of a range of IP addresses against which we could correlate events. Given an entry of say, '192.168.0.0/24', we'd like to be able to ascertain whether or not a source or destination IP address falls in the range.
<br>
The inlist operator (Reference Guide, Chapter 6, Sentinel Correlation Engine RuleLG Language, page 6-3) would be wonderful, if we could extend to it some functionality - that is, if we could store an IP address range in CIDR notation, then use the 'match regex' or 'match subnet' operators to match a list item against an IP address present in an incoming event.
<br>

<br>
]]></description>
<environment> <![CDATA[]]></environment>
<key id="87113">SEN-8448</key>
<summary>CIDR-enabled dynamic lists</summary>
<type id="4">Enhancem ent</type>
<priority id="5">Trivial </priority>
<status id="1">Open</status>
<resolution>Unr esolved</resolution>
<assignee username="patta biraman.sriniva san">Pattabiram an Srinivasan</assignee>
<reporter username="peng. liu">Peng Liu</reporter>
<created>Fri, 11 Jul 2008 14:07:41 -0400 (EDT)</created>
<updated>Fri, 11 Jul 2008 14:07:41 -0400 (EDT)</updated>
<version>6.1.0. 17</version>
<version>6.0.0. 0_SP2_Hotfix4</version>

<component>Corr elation</component>
<component>Dyna mic Lists</component>
<due></due>
<votes></votes>
<customfields >
</customfields>
</item>
</channel>
</rss>

With the above XSLT, i am getting two <bug></bug> tags with the same version ie, 6.1.0.17 instead of getting each with one version of input xml file.

Any help in this regard is highly appreciated.

Thanks,
Saritha
Sep 15 '08 #1
3 3686
Dormilich
8,658 Recognized Expert Moderator Expert
see line 15 of your xsl file:
Expand|Select|Wrap|Line Numbers
  1. <xsl:value-of select="version" />
you access all version child elements (the node-set resp), not a special one. If you want to make one <bug> per <version>, loop over <version>.

regards
Sep 15 '08 #2
jkmyoung
2,057 Recognized Expert Top Contributor
Agreed, you're looping on the version too early. If you wanted to do it that way, you'd have to pass in a parameter specifying which version you're pointing to.
But that's messy. Do it the other way instead.

Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="status = 'Open'">
  2.   <!-- removed for-each>
  3.     <xsl:apply-templates select="/rss/channel/item"/>
  4. </xsl:if>
  5. </xsl:for-each>
  6. </bugzilla>
  7. </xsl:template>
  8.  
  9. <xsl:template match="item">
  10.   <xsl:for-each select="version">
  11.     <bug>
  12.       <version>
  13.         <xsl:value-of select="." />
  14.       </version>
  15.     </bug>
  16.   </xsl:for-each>
  17. </xsl:template>
  18. </xsl:stylesheet>
  19.  
Sep 16 '08 #3
saritha2008
9 New Member
Hi, Thanks for your reply. I tried passing a parameter to template and now iam able to repeat for each version.

Below is the xslt that worked fine:

<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<bugzilla version="3.0.4" urlbase="http://172.16.6.51/proj11/" maintainer="sun itha.akula@appl abs.com" exporter="sunit ha.akula@applab s.com">
<!--Repeat the below for all the bugs in the xml-->
<xsl:for-each select="/rss/channel/item">
<xsl:if test="status = 'Open'">
<xsl:for-each select="version ">
<xsl:apply-templates select="ancesto r::item">
<xsl:with-param name="AffectsVe rsion" select="."/>
<xsl:with-param name="FixVersio n" select='string( "")'/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</bugzilla>
</xsl:template>
<xsl:template match="item">
<xsl:param name="AffectsVe rsion"/>
<xsl:param name="FixVersio n"/>
<bug>
<version>
<xsl:value-of select="$Affect sVersion" />
</version>
</bug>
</xsl:template>

</xsl:stylesheet>


Thanks,
Saritha

Agreed, you're looping on the version too early. If you wanted to do it that way, you'd have to pass in a parameter specifying which version you're pointing to.
But that's messy. Do it the other way instead.

Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="status = 'Open'">
  2.   <!-- removed for-each>
  3.     <xsl:apply-templates select="/rss/channel/item"/>
  4. </xsl:if>
  5. </xsl:for-each>
  6. </bugzilla>
  7. </xsl:template>
  8.  
  9. <xsl:template match="item">
  10.   <xsl:for-each select="version">
  11.     <bug>
  12.       <version>
  13.         <xsl:value-of select="." />
  14.       </version>
  15.     </bug>
  16.   </xsl:for-each>
  17. </xsl:template>
  18. </xsl:stylesheet>
  19.  
Sep 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2683
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the...
0
2022
by: M.sajjad | last post by:
Five Steps to Rapid Development with TierDeveloper 3.0 Unlock the power of rapid development when you use TierDeveloper from AlachiSoft in your N-Tier application development. Follow the steps below to quickly design, generate, and deploy a great portion of your real-life N- Tier application. For free evaluation download please visit...
2
1248
by: sneill | last post by:
Hello all, In the August 2003 edition of "XML Journal" (see: http://xml.sys-con.com/read/40671.htm) Pietro Michelucci wrote an interesting article entitled "Object-Oriented XSLT". The article described how, using a controller XSLT one could apply serial transformations to a data source. Does anyone have the source code that accompanied...
1
1913
by: Peran | last post by:
If I create a simple xslt stylesheet I can quickly test this in VS2005 by pressing the "Show XSLT Output" button rather than running the whole solution. If I then create a xslt stylesheet with some extended functions I have to run the whole solution (adding the extension objects to the XsltArgumentList when calling...
5
3577
by: kebabkongen | last post by:
Hi, I have an XML source which gives me the start time (in the format hh:mi) of a program and the duration of the program (in minutes). With XSLT only, I would like to generate the time the next program starts. Ex: If the current program starts at 10:30 and lasts for 60 minutes, I wish to display that the next program starts at 11:30. The...
3
3312
by: shaun roe | last post by:
mild rant follows Working now for a couple of years with xslt and now xslt 2.0, does anyone else get the impression that xslt 2.0 somehow missed the point? Yes its got a fancy new data model (and thank goodness for the new grouping functions), but where are the functions which would really have made it useful without taxing the...
1
3442
by: CAM123 | last post by:
I have added: <br><xsl:value-of select="Line" /></br> to my XSLT stylesheet to get a line per repeating block. When I view the output as XML it looks perfect - one line per block. However when I output the file to a text file, all the data is wrapping and at the end of each block I am getting the text part of the header included but not...
0
1254
by: Junior | last post by:
I need to learn which pattern or some coding methodology I should use to repeat all of the steps when using a Wizard control. Each iteration of the Wizard has 10 steps each of which collects data. The Wizard maintains state in ViewState but there could easily be as many as 10 iterations required collecting data from 10 steps per iteration....
0
7349
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7735
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7688
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5885
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5271
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
636
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.