473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XSL Template Question (Layout)

17
Does anyone know how I can get the horizontal template boxes to line up? The Network Interface and the IP Address boxes are within a different node so they show up below the Exchange Servers, Replication Required, and Setup Required boxes. (See picture for details). My guess it has something to do with the way I’m using the for-each select parameter.

Below is my XSL StyleSheet. (I’m using XML version 1.0 for my XML document).

Expand|Select|Wrap|Line Numbers
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  3. <xsl:template match="/">
  4.   <html>
  5.    <body>
  6.      <body bgcolor="Silver">
  7.    </body>
  8.      <h2>Exchange Server Information</h2>
  9.      <table border="3"> 
  10.       <tr bgcolor="yellow">
  11.           <th>Exchange Servers</th>
  12.         <th>Replication Required</th>
  13.         <th>Setup Required</th>
  14.         <th>Network Interface</th>
  15.         <th>IP Address</th>
  16.       </tr>    
  17.       <xsl:for-each select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com']|
  18.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']|
  19.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']|    
  20.  
  21.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='157.54.98.16']| 
  22.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='157.54.61.141']| 
  23.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='10.31.127.204']"> 
  24.       <tr>
  25.  
  26.            <td><xsl:value-of select="@Fqdn"/></td>
  27.            <td><xsl:value-of select="@RequiresReplication"/></td>
  28.            <td><xsl:value-of select="@RequiresSetup"/></td>
  29.            <td><xsl:value-of select="@InterfaceSide"/></td>
  30.            <td><xsl:value-of select="@IPAddress"/></td>
  31.       </tr>
  32.       </xsl:for-each>
  33.     </table>
  34.    </body>
  35.   </html>
  36. </xsl:template>
  37. </xsl:stylesheet>
Attached Images
File Type: jpg Example2.jpg (19.0 KB, 148 views)
Apr 5 '10 #1

✓ answered by Dormilich

there’s one closing </xsl:for-each> missing (started at line #18)

6 1912
jkmyoung
2,057 Expert 2GB
The best way I can think of to do this would be:
Expand|Select|Wrap|Line Numbers
  1.       <xsl:apply-templates select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com'|
  2. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']|
  3. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']"/>
  4.  
  5. -- template outside the main template:
  6. <xsl:template match="Cluster">
  7.       <tr> 
  8.            <td><xsl:value-of select="@Fqdn"/></td> 
  9.            <td><xsl:value-of select="@RequiresReplication"/></td> 
  10.            <td><xsl:value-of select="@RequiresSetup"/></td> 
  11.            <td><xsl:value-of select="Machine/NetInterface/@InterfaceSide"/></td> 
  12.            <td><xsl:value-of select="Machine/NetInterface/@IPAddress"/></td> 
  13.       </tr> 
  14.       <xsl:for-each select="Machine/NetInterface[position &gt; 1]">
  15.         <tr>
  16.            <td/><!--@Fqdn--> 
  17.            <td/><!--@RequiresReplication-->
  18.            <td/><!--@RequiresSetup--> 
  19.            <td><xsl:value-of select="@InterfaceSide"/></td> 
  20.            <td><xsl:value-of select="@IPAddress"/></td> 
  21.         </tr>
  22.       </xsl:for-each>
  23. </xsl:template>
  24.  
Apr 6 '10 #2
GabeGGG
17
Thanks, but I'm not sure how I would add your code to my below stylesheet. Can you add your code to my style sheet below so that I can get an idea?

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version='1.0'?>
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  4. <xsl:template match="/">
  5.   <html>
  6.    <body>
  7.      <body bgcolor="Silver">
  8.    </body>
  9.      <h2>Exchange Server Information</h2>
  10.      <table border="3"> 
  11.       <tr bgcolor="yellow">
  12.           <th>Exchange Servers</th>
  13.         <th>Replication Required</th>
  14.         <th>Setup Required</th>
  15.         <th>Network Interface</th>
  16.         <th>IP Address</th>
  17.       </tr>    
  18.       <xsl:for-each select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com']|
  19.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']|
  20.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']|    
  21.  
  22.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='1.1.1.1']| 
  23.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='2.2.2.2']| 
  24.                             DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster/Machine/NetInterface[@IPAddress='3.3.3.3']"> 
  25.       <tr>
  26.  
  27.            <td><xsl:value-of select="@Fqdn"/></td>
  28.            <td><xsl:value-of select="@RequiresReplication"/></td>
  29.            <td><xsl:value-of select="@RequiresSetup"/></td>
  30.            <td><xsl:value-of select="@InterfaceSide"/></td>
  31.            <td><xsl:value-of select="@IPAddress"/></td>
  32.       </tr>
  33.       </xsl:for-each>
  34.     </table>
  35.    </body>
  36.   </html>
  37. </xsl:template>
  38. </xsl:stylesheet>
  39.  
Apr 6 '10 #3
jkmyoung
2,057 Expert 2GB
from the for-each:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. <xsl:for-each select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com']|
  3. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']|
  4. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']">
  5. <tr>  
  6.            <td><xsl:value-of select="@Fqdn"/></td>  
  7.            <td><xsl:value-of select="@RequiresReplication"/></td>  
  8.            <td><xsl:value-of select="@RequiresSetup"/></td>  
  9.            <td><xsl:value-of select="Machine/NetInterface/@InterfaceSide"/></td>  
  10.            <td><xsl:value-of select="Machine/NetInterface/@IPAddress"/></td>  
  11.       </tr>  
  12.       <xsl:for-each select="Machine/NetInterface[position &gt; 1]"> 
  13.         <tr> 
  14.            <td/><!--@Fqdn-->  
  15.            <td/><!--@RequiresReplication--> 
  16.            <td/><!--@RequiresSetup-->  
  17.            <td><xsl:value-of select="@InterfaceSide"/></td>  
  18.            <td><xsl:value-of select="@IPAddress"/></td>  
  19.         </tr> 
  20.       </xsl:for-each> 
  21.     </table> 
  22. ...
  23.  
Notice most of the Machine/NetInterface handling is dealt within the nested for-each loop
I guess there's no real need for an extra template if the code is this short.
Apr 6 '10 #4
GabeGGG
17
I get the attached error. I have a feeling my styleesheet is not correct. What do you think?

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version='1.0'?>
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  4. <xsl:template match="/">
  5.   <html>
  6.    <body>
  7.      <body bgcolor="Silver">
  8.    </body>
  9.      <h2>Exchange Server Information</h2>
  10.      <table border="3"> 
  11.       <tr bgcolor="yellow">
  12.           <th>Exchange Servers</th>
  13.         <th>Replication Required</th>
  14.         <th>Setup Required</th>
  15.         <th>Network Interface</th>
  16.         <th>IP Address</th>
  17.       </tr>    
  18.    <xsl:for-each select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com']| 
  19. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']| 
  20. DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']"> 
  21. <tr>   
  22.            <td><xsl:value-of select="@Fqdn"/></td>   
  23.            <td><xsl:value-of select="@RequiresReplication"/></td>   
  24.            <td><xsl:value-of select="@RequiresSetup"/></td>   
  25.            <td><xsl:value-of select="Machine/NetInterface/@InterfaceSide"/></td>   
  26.            <td><xsl:value-of select="Machine/NetInterface/@IPAddress"/></td>   
  27.       </tr>   
  28.       <xsl:for-each select="Machine/NetInterface[position &gt; 1]">  
  29.         <tr>  
  30.            <td/><!--@Fqdn-->   
  31.            <td/><!--@RequiresReplication-->  
  32.            <td/><!--@RequiresSetup-->   
  33.            <td><xsl:value-of select="@InterfaceSide"/></td>   
  34.            <td><xsl:value-of select="@IPAddress"/></td>   
  35.         </tr>  
  36.       </xsl:for-each>  
  37.     </table>  
  38.    </body>
  39.   </html>
  40. </xsl:template>
  41. </xsl:stylesheet>
  42.  
Attached Images
File Type: jpg example4.jpg (19.4 KB, 166 views)
Apr 7 '10 #5
Dormilich
8,658 Expert Mod 8TB
there’s one closing </xsl:for-each> missing (started at line #18)
Apr 7 '10 #6
GabeGGG
17
That did it!!!!

Expand|Select|Wrap|Line Numbers
  1. <?xml version='1.0'?> 
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> 
  3. <xsl:template match="/"> 
  4.   <html> 
  5.    <body> 
  6.      <body bgcolor="Silver"> 
  7.    </body> 
  8.      <h2>Exchange Server Information</h2> 
  9.      <table border="3">  
  10.       <tr bgcolor="yellow"> 
  11.           <th>Exchange Servers</th> 
  12.         <th>Replication Required</th> 
  13.         <th>Setup Required</th> 
  14.         <th>Network Interface</th> 
  15.         <th>IP Address</th> 
  16.       </tr>     
  17.    <xsl:for-each select="DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='exch-dc-08.contoso.microsoft.com']|  
  18.                          DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='tk5ucdfpp01.contoso.microsoft.com']|  
  19.                          DocItemSet/DocItem/Data/AnchoredXml/Dictionary/Item/Value/Topology/Clusters/Cluster[@Fqdn='b43ucdfms01.contoso.microsoft.com']">  
  20. <tr>    
  21.            <td><xsl:value-of select="@Fqdn"/></td>    
  22.            <td><xsl:value-of select="@RequiresReplication"/></td>    
  23.            <td><xsl:value-of select="@RequiresSetup"/></td>    
  24.            <td><xsl:value-of select="Machine/NetInterface/@InterfaceSide"/></td>    
  25.            <td><xsl:value-of select="Machine/NetInterface/@IPAddress"/></td>    
  26.       </tr>  
  27. </xsl:for-each>  
  28.       <xsl:for-each select="Machine/NetInterface[position &gt; 1]">   
  29.         <tr>   
  30.            <td/><!--@Fqdn-->    
  31.            <td/><!--@RequiresReplication-->   
  32.            <td/><!--@RequiresSetup-->    
  33.            <td><xsl:value-of select="@InterfaceSide"/></td>    
  34.            <td><xsl:value-of select="@IPAddress"/></td>    
  35.         </tr>   
  36.       </xsl:for-each>   
  37.     </table>   
  38.    </body> 
  39.   </html> 
  40. </xsl:template> 
  41. </xsl:stylesheet> 
  42.  
Apr 7 '10 #7

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

Similar topics

21
by: PassingBy | last post by:
I recently came across a template site selling cd's and was wondering what the groups opinion is of this? I purchased one of the cd's and the templates are great and Im looking forward to...
1
by: Abhishek Srivastava | last post by:
Hello All, In almost all websites which I have developed, we need to follow a layout template (header, footer, menu on left hand side etc) In ASP.NET solutions, we can do this in two ways ...
6
by: briand | last post by:
How do I make many pages with the same layout? I have created header, side bar, main body, and footer web controls and added them to a table. I have many pages that want to use this same layout,...
3
by: Andy Lim | last post by:
I'm currently working on my second web application using VS 2003/VB.NET, after moved from Dreamweaver MX. one thing that i missed so much in VS2003 is DWMX's great visual, WYSIWYG layout design,...
1
by: Capior | last post by:
hello, i've created - as described in http://www.asp-buch.de/articles/2002-06-26-1.aspx - a global layout for my website. now i want to use some code/variables in it. but as far as i use <%...
16
by: Jef Driesen | last post by:
I have created a nice idea for a website and now I would like to translate that idea in (x)html and css. The layout is quite basic: a header, two columns and a footer. For a graphical presentation,...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
0
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your...
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
2
by: Hendrik Schober | last post by:
Hi, the following code is the boiled-down version of something that gives us trouble on GCC. In the real code, 'F' is some fixed-size array class, 'Q' and 'V' are derived classes that probably...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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,...

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.