473,385 Members | 1,944 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,385 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 4339
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.