473,396 Members | 1,859 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.

How to handle Missing Child Element

25
I have an XML want and output in HTML so using and XSL for that. The XML file i am using

<property ref="1">
<units>
<unit ref="1">first floor</unit>
<unit ref="2">second floor</unit>
<unit ref="3">third floor</unit>
<unit ref="4">fourth floor</unit>
</units>
<leases>
<lease ref="1">OPEN</lease>
<lease ref="2">CLOSE</lease>
<lease ref="3">OPEN</lease>
</leases>
</property>

I want to find out the HTML output where the property unit compared with lease. Facing problem when unit ref="4" but dont find out lease with same ref so want a text against that
Jan 22 '08 #1
5 4342
jkmyoung
2,057 Expert 2GB
Not entirely sure what you're doing

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="unit">
  2.   <tr>
  3.     <td><xsl:value-of select="."/></td>
  4.     <xsl:variable name="lease">
  5.       <xsl:choose>
  6.         <xsl:when test="//lease[@ref = current()/@ref]"/>
  7.           <xsl:value-of select="//lease[@ref = current()/@ref]"/>
  8.         </xsl:when>
  9.         <xsl:otherwise>not found</xsl:otherwise>
  10.       </xsl:choose>
  11.      </xsl:variable>
  12.     <td><xsl:value-of select="$lease"/></td>
  13.   </tr>
  14. </xsl:template>
  15.  
Jan 22 '08 #2
rupak
25
Not entirely sure what you're doing

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="unit">
  2.   <tr>
  3.     <td><xsl:value-of select="."/></td>
  4.     <xsl:variable name="lease">
  5.       <xsl:choose>
  6.         <xsl:when test="//lease[@ref = current()/@ref]"/>
  7.           <xsl:value-of select="//lease[@ref = current()/@ref]"/>
  8.         </xsl:when>
  9.         <xsl:otherwise>not found</xsl:otherwise>
  10.       </xsl:choose>
  11.      </xsl:variable>
  12.     <td><xsl:value-of select="$lease"/></td>
  13.   </tr>
  14. </xsl:template>
  15.  

Thanks for the reply, i tried it but it is giving the output that i want and looking for but also and extra values of lease i.e.

first floor OPEN
second floor CLOSE
third floor OPEN
fourth floor not found
OPENCLOSEOPEN

I want to remove last line
Jan 24 '08 #3
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="/">
  2.   <html>
  3.     <body>
  4.       <xsl:apply-templates select="//unit"/>
  5.     </body>
  6.   </html>
  7. </xsl:template>
  8.  
Jan 24 '08 #4
rupak
25
Thanks for the reply, i tried it but it is giving the output that i want and looking for but also and extra values of lease i.e.

first floor OPEN
second floor CLOSE
third floor OPEN
fourth floor not found
OPENCLOSEOPEN

I want to remove last line

You have helped me with removing the last line, thanks for the help.

Now my requirement has changed bit further.

Presently my O/p is as below:

first floor OPEN
second floor CLOSE
third floor OPEN
fourth floor not found

Now I want to show O/p:

first floor OPEN

with
Prev. & Next Button
On click of them will move to

second floor CLOSE

with
Prev. & Next Button
On click of them will move to

third floor OPEN

Simillarly till the last record.
Mar 28 '08 #5
I can't understand ur problem clearly. But try like this

<xsl:if text="unit[@ref]">
<xsl:value-of select="@ref"/>
</xsl:if>

<xsl:if text="lease[@ref]">
<xsl:value-of select="@ref"/>
</xsl:if>

-----------------------------------------------------------------------------------------------------



I have an XML want and output in HTML so using and XSL for that. The XML file i am using

<property ref="1">
<units>
<unit ref="1">first floor</unit>
<unit ref="2">second floor</unit>
<unit ref="3">third floor</unit>
<unit ref="4">fourth floor</unit>
</units>
<leases>
<lease ref="1">OPEN</lease>
<lease ref="2">CLOSE</lease>
<lease ref="3">OPEN</lease>
</leases>
</property>

I want to find out the HTML output where the property unit compared with lease. Facing problem when unit ref="4" but dont find out lease with same ref so want a text against that
Mar 31 '08 #6

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

Similar topics

14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
7
by: Markus Ernst | last post by:
Hello I try to hanlde events centrally for avoiding the need to write four event handler attributes to every link. The task is changing the class name of a link's containing <div> element. After...
1
by: George W. | last post by:
Okay, I'm a C#/XML newbie, and I've been wrestling with this for a while now, checked dotnet sites, articles, MSDN Library, etc. and haven't been able to determine why this is happening. I have...
0
by: Alberto Grosso Nicolin | last post by:
We have the following XML schema: there's a root element (Response) with of a single child element (Result). ...
3
by: Robert | last post by:
I have a number of web projects converted from 1.1 to 2.0 in VS2005. I am methodically seeing the error below: The element 'compilation' has invalid child element 'compilers'. List of...
4
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a...
2
by: Paulers | last post by:
Hello all, I am trying to parse an XML document and populate objects to store in an ArrayList but I am having issues when an element is NULL. I cant seem to figure out how to handle it. I keep...
5
by: mareeus | last post by:
Hi, Let's say we have the following html code (a body with some forms): <html> <head> </head> <body> <form name="form1" action="#">
3
by: Marcolino | last post by:
Hi all, I have an MDI container and some child. I need to retrive Form Object from its handle, but it seems that for MDI child the following code i'm using is not working and will return me...
2
by: Claudia Fong | last post by:
Hi, I have a xml document which is like this: <profile document> <Child name = profile1 id = 1> </Child> </profile document>
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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.