• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Radiobuttons in XML and XSL

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
First: Sorry, my english is not the best, but I try to write as good as possible.
Second: I'm new to XML....

My Problem:
I want to make 2 Radiobuttons in my XML file to decide "yes" and "no". I also have a XSL file, which makes it difficult for me.
What should be the code in my XML file, and what should be the code in my XSL file?

I tried different solutions of Google, but they also don't work. Maybe somebody can help me!

Thank you very much! Best regards!


 
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

XML radiobuttons are called Boolean integers. A Boolean integer can be one of only two values : TRUE or FALSE.

http://www.w3.org/TR/xmlschema-2/#boolean

You can also have an enumeration, which is a list of possible values in a String datatype, for scenario where you have several radiobuttons that are related.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not clear what you mean by "radiobuttons" in the context of XML (which is not by itself a GUI technology). Can you be more specific? Like what kinds of XML inputs you have, what kinds of output the XSL produces, etc.

Also, tell us what the two "solutions" were you tried, and how they didn't work.
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Ulf - I suppose OP has a GUI and wants to send the data from the GUI to a server. Mario's question is how to represent some of the data from his GUI in an XML payload, and how to specify the XSD for that payload. If there are only two radiobuttons that mutually exclude each other, you can use a Boolean. Else, an enumeration.
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo! Thank you for your answers!

I want to have radiobuttons to be able to select between YES and NO.

I have tried this:

XML:




In the final Version there should be 2 radiobuttons - one should be checked, the other not.
I hope you understand my Problem and can help me...

Thank you so much!
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just defining these elements in XML does not 'automagically' pop the user interface elements onto the screen. What language are you programming your GUI in ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the output would be HTML? If you want to model a yes/no decision then a checkbox would be a more common approach.
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:So the output would be HTML? If you want to model a yes/no decision then a checkbox would be a more common approach.


Really? But with a checkbox I am able to "check" both checkboxes, right? And with a radiobutton I can model that Im just allowed to "check" one Radiobutton. But I'm not sure if I'm right..
Can you tell me a solution with a checkbox? I would like to try it.

Yes, the output would be HTML.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to model a yes/no decision where you can check both?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your target is HTML, then you should be designing your desired HTML. Do not think about XML or XSLT until you know what HTML you want to generate. Otherwise you are guilty of writing code before you know what you want that code to achieve.
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You want to model a yes/no decision where you can check both?


No, only one. Is it possible, if yes, how?

Paul:
You are right, but I now what I want. Just something where it is possible to decide between yes and no. So i would like to model radiobuttons/checkboxes.

Thanks for all answeres :-)
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question was really: radio buttons are for selecting one of several. If it's just a yes/no decision, why not use a checkbox (which HTML also has)?
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:My question was really: radio buttons are for selecting one of several. If it's just a yes/no decision, why not use a checkbox (which HTML also has)?



If it works, i will not be against it.
But I don't know how to model it with checkboxes. I will try tomorrow.

Maybe somebody know how it works and can help me, according to the code above...

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML includes both checkboxes and radio buttons. To model "yes/no" you could use one checkbox or two radio buttons.
 
Ranch Hand
Posts: 734
7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Mario Huber
You have to undertake to look very carefully into this demo which is the best I can abstract from some of the elements your posts shown. If you see something you don't understand, you google and read tutorials to fill the gap. In a sense, it is not the best way to learn xml from xslt, even less html from xsl.

xml document

xslt document
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@g tsuji

Thank you very much!
I tried your code in complete new empty files, the code worked very fine!

BUT ( :-( ) in my existing files it doesn't work. I think it depends on the body-tag - I already have a Body tag in my XSL file.

I have adapted the code a little bit, like you can see below.
For all: I have to change a clinical architecture document for discharching patients in a Hospital.

In the XML file it is like g_tsuji posted above! Here are the whole file: http://www.xup.in/dl,927jo125kl32346/ELGA-Entlassungsbrief_Pflege_EIS-FullSupport.xml/

Here are the code of my XSL file:
http://www.xup.in/dl,136l2455294/ELGA_Stylesheet_v1.0.xsl/

Please search to "REZEPTGEBÜHRENBEFREIUNG" - I made comments to the important lines!

I hope anybody can help me with my Problem.

And sorry because of my english, i hope you understand me...

Thank you very much!
Best regards!
 
g tsuji
Ranch Hand
Posts: 734
7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've taken a quick look of them. These are the issues and other suggestions.

[1] The (global) variable rezeptgebbefr would set up a node of its own. Hence, when you insert it to the page, it is not xsl:value-of which would result in concat its text. Instead, you ought to use xsl:copy-of.

[2] When you define the (global) variable rezeptgebbefr, two fine points you've to taken care of.
[2.1] Your html carries the xhtml namespace. In order to keep form and input in that namespace as well (for consistency purpose), their direct constructor has to make their namespace explicit (that's the way it performs - and one can sure hope it make their way in automatically, but it is just not to do it without telling.)
[2.2] Here is another less well-known element. Since the templates going to be applied serve some special purpose with special construction. In order not to interfere with other possibly less specific templates matching the same element rezeptgebuehrenbefreiung, you better fence it with a mode attribute with some specific but arbitrary value, say "form-construct". The variable would look like this.

[3] Related to [2] is to set up the mode for the template actually run. Also this time I would add an xsl:for-each to make the logic more explicit.

The radio buttons will be rendered in the output. Whether it appears or not, it depends on the chain of template matchings. It may or may not called. But if it is called at all in the xslt, the radio buttons and the form would appear in the output html.
 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you SOOOO much! It works!

BUT

I got an error because of the "select" in this attribute:


I removed the select statement and it worked. Is it a problem that I have removed it?

Best regards!!
 
g tsuji
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I typed without thinking too much. It should read like this like you did:

or, that's what I'd in mind.

 
Mario Huber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem, I like it better when nothing is predefined checked! :-)

Thank you again!
 
reply
    Bookmark Topic Watch Topic
  • New Topic