473,606 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to re-arrange the value of an XML element while displaying

1 New Member
XML
-----
Expand|Select|Wrap|Line Numbers
  1. <vdu vdu_id="4b8febcd000000000a5901f2232f0002"> 
  2. <field><name>vdu_id</name><value>4b8febcd000000000a5901f2232f0002</value></field> 
  3. <Field><Name>ANI</Name><Value></Value> 
  4. </Field> 
  5. <Field><Name>AccountNumber</Name><Value></Value> 
  6. </Field> 
  7. <Field><Name>ERMCaseCategory</Name><Value></Value> 
  8. </Field> 
  9. <Field><Name>ERMCaseId</Name><Value></Value> 
  10. </Field>
  11. <Field><Name>extradata</Name><Value></Value> 
  12. <Container count="6"> 
  13. <Field><Name>emailtype</Name><Value>NOR</Value> 
  14. </Field> 
  15. <Field><Name>messageId</Name><Value>589</Value> 
  16. </Field> 
  17. <Field><Name>tenantLogoURL</Name><Value></Value> 
  18. </Field> 
  19. <Field><Name>tenant_key</Name><Value>2</Value> 
  20. </Field> 
  21. <Field><Name>tenantname</Name><Value>IMLGTenant</Value> 
  22. </Field> 
  23. <Field><Name>trackingNumber</Name><Value>T201003040002</Value> 
  24. </Field> 
  25. </Container> 
  26. </Field> 
  27. </vdu>
XSL
-----

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  4. <TITLE>eDU Viewer</TITLE>
  5. </HEAD>
  6. <BODY STYLE="border: 0px; margin: 0px; font-family: arial; font-style: bold;font-size: 10pt">
  7. <xsl:for-each select="vdu">
  8. <TABLE BORDER="1" CELLSPACING="1" CELLPADDING="1" STYLE="border:0px; margin: 0px; 
  9. font-family: arial; font-style: bold;font-size: 8pt">
  10. <xsl:for-each select="Field[not(Container or IndexedContainer)]">
  11. <xsl:apply-templates/>
  12. </xsl:for-each>
  13.  
  14. <xsl:for-each select="Field[Container or IndexedContainer]">
  15. <xsl:choose>
  16. <xsl:when test="Name[. = 'customerInfo']">
  17. <TR><TD bgcolor="yellow" align="center" colspan = "2"><B>Customer Information</B></TD></TR>
  18. <xsl:apply-templates/>
  19. </xsl:when>
  20. <!-- Put list of top level containers that should be displayed -->
  21. <!-- nested containers require additional customization -->
  22. <xsl:when test="yellow[. = 'xxContainerNamexx']">
  23. <TR><TD bgcolor="red" align="center" colspan="2"><B>xx Container Name xx</B></TD></TR>
  24. <xsl:apply-templates/>
  25. </xsl:when>
  26. </xsl:choose>
  27. </xsl:for-each>
  28. </TABLE>
  29. </xsl:for-each>
  30. </BODY>
  31. </HTML>
  32. </xsl:template>
  33.  
  34. <xsl:template match="Field[not(Container or IndexedContainer)]/Name">
  35. <xsl:apply-templates select="Field/Name[. = 'ERMCaseId']"/>
  36. <xsl:apply-templates select="Field/Name[. = 'AccountNumber']"/>
  37. <xsl:apply-templates select="Field/Name[. = 'ERMCaseCategory']"/>
  38. </xsl:template>
  39.  
  40. <xsl:template match="Field/Name[. = 'ERMCaseId']">
  41. <xsl:if test="../Name[. = 'ERMCaseId']"><TR><TD><TH ALIGN="left">ERM CASE ID</TH></TD><TD><xsl:value-of select="../Value"/></TD></TR></xsl:if>
  42. </xsl:template>
  43.  
  44. <xsl:template match="Field/Name[. = 'AccountNumber']">
  45. <xsl:if test="../Name[. = 'AccountNumber']"><TR><TD><TH ALIGN="left">ACCOUNT NUMBER</TH></TD><TD><xsl:value-of select="../Value"/></TD></TR></xsl:if>
  46. </xsl:template>
  47.  
  48. <xsl:template match="Field/Name[. = 'ERMCaseCategory']">
  49. <xsl:if test="../Name[. = 'ERMCaseCategory']"><TR><TD><TH ALIGN="left">ERM CASE CATEGORY</TH></TD><TD><xsl:value-of select="../Value"/></TD></TR></xsl:if> 
  50. </xsl:template> 

I want to display in this order

ERM CASE ID
ACCOUNT NUMBER
ERM CASE CATEGORY

but my display comes in the order of source xml file

ACCOUNT NUMBER
ERM CASE CATEGORY
ERM CASE ID
Mar 6 '10 #1
1 1512
jkmyoung
2,057 Recognized Expert Top Contributor
Use select="."
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="Field[not(Container or IndexedContainer)]"> 
  2.   <xsl:apply-templates select="."/> 
  3. </xsl:for-each> 
  4.  
Mar 8 '10 #2

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

Similar topics

1
4282
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would be better to promote better programming than rely on PHP to compensate for lazy programming?
4
6416
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
1
4089
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again for adding so much code... <TABLE border="1" bordercolor="#000000" cellspacing="0"> <TR>
11
3996
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
18522
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function blocks until something.exe terminates. Just what I /don't/ want. (Wouldn't an & be nice here! Sigh) I need something.exe to disconnect and run in the background while I
1
3691
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with sockets??
10
4210
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
3650
by: Lothar Scholz | last post by:
Because PHP5 does not include the mysql extension any more is there a chance that we will see more Providers offering webspace with Firebird or Postgres Databases ? What is your opinion ? I must say that i like it to see mysql replaced by a real database (stored procedures etc.)
1
3630
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id NOT IN ( SELECT manufacturers_id FROM products )
3
3471
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with the variable $GET but $GET is not a variable, I thought it came from the page that calls the PHP file? if(($_GET)==""){ this gets an error
0
7978
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8126
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6796
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5470
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.