optional

find whether an element exists by a particular tag name in XML

Hi I have an XML file where some sub tags (child node elements) are optional. e.g. <part> <note> </rest> </note> <note> <pitch></pitch> </note> <note> <pitch></pitch> </note> </part> But when I read the XML files by tags, it throws a NullPointerException - since some sub-tags are optional (e.g...

Is there a way to use default arguments that are the result of a function call in VB.NET?

I have a whole slew of database access functions which assume a particular connection string. Within my application I call myList = DB_MyTable.GetTableItems() and within GetTableItems() I have something like Dim connection As SqlConnection = MyDB.GetConnection So the connection string is in one place in the code, and I call a meth...

Regexp pattern Optional character

I want to match a string like 19740103-0379 or 197401030379, i.e the dash is optional. How do I accomplish this with regexp? ...

Handling Optional APIs in J2ME

What is the right way of working with optional APIs in Java Mobile? Does one need to make different versions of their app? Or is it enough to check APIs availability at runtime using System.getProperty()? Let's say I'd like my app to support JSR-256 (the Sensor API). Would importing classes from javax.microedition.sensor and register...

Optional foreign key with django?

Hi, In my models I want to have an optional field to a foreign key. I tried this: field = models.ForeignKey(MyModel, null=True, blank=True, default=None) But i am getting this error: model.mymodel_id may not be NULL i am using sqlite edit: if it can help, here is the exception location: /usr/lib/python2.6/site-packages/django/d...

haskell parsec optional question

Sorry if it's a novice question - I want to parse something defined by Exp ::= Mandatory_Part Optional_Part0 Optional_Part1 I thought I could do this: proc::Parser String proc = do { ;str<-parserMandatoryPart ;str0<-optional(parserOptionalPart0) --(1) ;str1<-optional(parserOptionalPart1) --(2) ;return str++str0+...

WPF Optional Binding

I have an existing XAML file with some data templates in it. One of these datatemplate can be used in different situations. Therefore, I want to bind 1 of the properties only if a certain condition is true. What is the best way to achieve this? ...

Lightweight boost::optional

I currently can't use boost in a project and I've found myself missing boost::optional. I've found this blog post which shows the idea behind boosts implementation. However, it doesn't take into account memory alignment issues and I'm not well versed enough in C++ to make the necessary changes. Does anyone know of an simple implement...