473,554 Members | 4,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml conditional if statement

3 New Member
Hello everyone,

I have a question about if statements with xml. I need to ensure certain fields have a particular value, if this is true I want to display a large amount of text. Let me give an example below:

if fld_Country="Ca nada"
if fld_City="Toron to"
if fld_Member="1"
display the following text, "blah blah."

if fld_country"USA "
if fld_city="New York"
if fld_member="2"
display the following text, "blah blah."

if fld_country"Can ada"
if fld_City="Toron to"
if fld_Member="2"
display the following text, "blah blah."

if fld_country"Can ada"
if fld_City="Ottaw a"
display the following text, "blah blah."

end if statements

I am not certain if this is possible to nest so many if statements within a single if statement. Should I use choices? Any advice would be greatly appreicated. Thanks.
Joe.

<code>
<?if@inlines:fl d_COUNTRY='Cana da'?>?fld_COUNT Y_DESCR?><?end if?>
</code>
Nov 11 '08 #1
6 27650
Dormilich
8,658 Recognized Expert Moderator Expert
what you want to do seems a bit strange. xml (with some exceptions) is used to store data (statically store, like in a DB).

any condition would need someone/something (that someone is usually called "parser") that actually decides if the condition is fulfilled or not. an xml parser doesn't do that.

in your case I recommend using a script that processes an input giving you the desired xml file.
- xslt (needs xml, returns xml or text)
- any programming language

for the case of xslt your “weapon” of choice is a conditional XPath expression, e.g.
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="element[fld_Country='Canada'][fld_City='Toronto'][fld_Member='1']">
  2. // note that the expression depends on your input xml
  3. <xsl:text>bla bla blubb</xsl:text>
  4. </xsl:template>
in any case I recommend reading a tutorial first, if you're not accustomed to the language you want to use.

XSLT tutorial

if you encounter any problems post back so we can help you getting it right.

regards
Nov 11 '08 #2
jkmyoung
2,057 Recognized Expert Top Contributor
Is the code actually formed like so?
<code>
<?if@inlines:fl d_COUNTRY='Cana da'?>?fld_COUNT Y_DESCR?><?end if?>
</code>

Is the fact that the last query has no Member signficant?

It really depends on how you're going to use your code.
Nov 12 '08 #3
joe2k1
3 New Member
Here is a quick follow up.

It would appear I am using XSLT processor.

I need to make certain two conditionals are true for a statement to print.

Unfortunately, I am having one the first statement found to be true and the message is printed!

<?choose:?>
<?when:GENDER=' MALE'?>
<?when:AGE='30' ?>
Please note that you have been selected to participate in a survery for men who are age 30 this year.
<?end when?>
<?end when?>
<?end choose?>

Here is the error message when I tried to process this syntax


<Line 103, Column 63>: XML-22047: (Error) Invalid instantiation of 'xsl:when' in 'xsl:when' context.


I am unable to determine the exact line but I am 99% certain it relates to the above coding.

Any help or advice would be greatly appreciated!

Thank you.
Feb 6 '09 #4
jkmyoung
2,057 Recognized Expert Top Contributor
You have a nested when. If you want to use a nested when you need to have to have a nested choose with it.
Expand|Select|Wrap|Line Numbers
  1. <choose>
  2.   <when>
  3.       <choose>
  4.           <when>
  5.  
Feb 6 '09 #5
joe2k1
3 New Member
I tried the nesting, but unfortunately it didn't work. Here is what I tried below:

<choose>
<when>
<choose>
<when>
if both when conditions are true please show this message.
end when
end choose
end when
end choose

is that logic correct?
Feb 6 '09 #6
jkmyoung
2,057 Recognized Expert Top Contributor
Does it work if you use nested ifs instead? Or nested ifs in the when?

I really have no idea as to what processes you're using to manufacture the code which manufactures the code.
Feb 12 '09 #7

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

Similar topics

7
9319
by: Shaldaman | last post by:
I have an Access form called "Login". "Command10" is a button on the form and "Text5" is a text field on it. When a user enters a value in the Text5 text field and clicks the button Command10, I want my function to check if the value in Text5 matches any value of InstructorID in the Instructor table. If yes, I would like the control to switch...
8
1642
by: arganx | last post by:
The conditional statement "if(j.... always executes regardless of what you enter. BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam) { char buffer=""; GetWindowText(hwnd,buffer,256); if(!strcmp(buffer,"")) { return TRUE;
5
2527
by: Gary Wessle | last post by:
Hi if I have a method like this bool myClass::myMothod(myType& mt, herType ht) throw ( SomeExp ); how can I use it in a conditional statement if ( try {
43
7542
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. How is it possible? Please help me. Thanks in advance.
5
2421
by: bamn68 | last post by:
how do i use conditional statement in sql? im using access 2003 as frontend and backend. What would be the SQL statement for the situation below? I would like to count the number of records in a table (ex. ENROLL) where there is only 1 instance of any value in a field (ex. STUDENT_NO) plus another condition where a given value (ex. 1) should...
0
1390
by: cljordan | last post by:
I am trying to create a database that list materials and their quantities, and highlights quantities that come up outside a certain percentage range against the average. I have tried the following conditional formatting: Condition 1: >Avg()*1.5; Condition 2: <Avg()*0.5 However, there are a lot of different materials that differ in...
0
7615
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7539
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
7819
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. ...
0
8055
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
7897
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...
1
5446
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
3566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
858
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.