Solved

Drop-down Menu in XML

Posted on 2004-08-09
4
643 Views
Last Modified: 2013-11-19

Hi,

Is it possible to have a drop-down menu, or something similar to it in XML Schema? I have an element called paymentFrequency and there are basicly 7 different possible types. How can I get it so that a person creating an XML document using my schema will end up picking one of these values in the paymentFrequency element?

Thanks
0
Comment
Question by:fyness
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 11755051
<form name="Form1">
<select name="paymentFrequency">
<option value="" selected="selected">Select one</option>
<xsl:for-each select="/....">
<option value="{PaymentFrequency}">
<xsl:value-of select="PaymentFrequency"/>
</option>
</xsl:for-each>
</select>
</form>
0
 
LVL 26

Accepted Solution

by:
rdcpro earned 125 total points
ID: 11758758
Use the Enumeration facet to restrict the string type:

<xsd:simpleType name="paymentFrequencyType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Here is one type"/>
    <xsd:enumeration value="Ok, this is good too."/>
    <xsd:enumeration value="Maybe you want this one?"/>
    <!-- and so on ... -->
  </xsd:restriction>
</xsd:simpleType>

Whether or not the application the person is using will provide a dropdown based on the schema is dependant on the editor itself.  Notepad, for example, doesn't care anything about schemas.  XML Spy, on the other hand, will examine the schema, and figure out what values are allowed in context.  When you create a new element of that type, XML Spy will show you a list of allowable values, for you to pick from.

Regards,
Mike Sharp
0
 

Author Comment

by:fyness
ID: 11760348

Thanks for your reply, just wanted clear something up.
So are you saying that I restrict the value using an attribute within the element of paymentFrequency?

Suzy
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 11763429
No, I'm saying the W3C XML Schema can restrict the value of paymentFrequency directly.  The Schema defines the content model for paymentFrequency.  There are a number of different ways to accomplish the same thing in Schema, and the above example showed one way, by defining a simpleType.  You then create your element declaration like:

<xs:element name = "paymentFrequency" type="user:paymentFrequencyType" />

I can only guess at the exact syntax, as it depends on how you've declared your namespace, and how you've constructed the schema.  So my example might not cut-and-paste into your schema, but it shows the approach.

Regards,
Mike Sharp
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question