XPath – how to find all elements where an attribute starts-with a text value

BronwenWeeGo.jpgToday i had to filter an xml document based on the start value of an attribute and it took me ages to work it out as before i’d always done exact matches.  Plus couldn’t find any egs where they used anything bar =.  So if i have a xml schema like


<books>
	<book name="Bronwens adventure"></book>
	<book name="Bronwen vacations"></book>
</books>

and i have a XMLDocument with this in it.  If i want to find all the book’s whose name starts with “Bronwen” I can do a xpath query as follows:


doc.SelectNodes("//book[starts-with(@name,'Bronwen');

mygeoland.com – for people that are sick of whereis

johnWeeGo.jpgmygeoland.com, the new way to search for places in Australia. Powered by Virtual Earth 3D and customised by Soul Solutions for Australia we believe it is the simplest, fastest and coolest way to find a street, suburb or place in Australia.

Go check it out: mygeoland.com

mygeoland2D.jpg
Simply double click the state, and start typing the street name and extension e.g. ‘smith st’
Because you centred the map on the state, the search box automatically populates the state and country. That’s right Virtual Earth has a powerful search engine for Australia but you need to know how to use it. Type in “Opera House” into local.live.com and you are taken to Boston, USA – you could say hello to Denny Crane but really it’s not that useful. Instead go to mygeoland.com, double click on NSW and type “Opera House”, that’s much better.

Ok so the site is quick, it’s easy to use, it works, but where is that cool part?

See that 3D button? Click on it to install Virtual Earth 3D into Internet Explorer. It’s still a beta but if you have XP SP2 (or better) and a 32MB video card you download 5.5mb and say goodbye to your afternoon. Its Google Earth in your browser and now with full search for Australia!

mygeoland3d.jpg
Click on the 3D, click on the map to give it focus and press Ctrl-Q. You have just entered first person mode! This is cool, mouse looks around and the WASD keys move you around like you’re in counter strike, c and space zoom, Esc to exit the mode.

So now we put this all together, in 3D mode we double click our state, click on the textbox (hope to remove this step ASAP), type in the street name and press enter – whoosh your zoomed in to the address. Now click on the map and press Ctrl-Q. Now you can explore the area! Is that cooler then the competition in Australia? At least they have NextG so we can have this on our phone!

So what have we done to put this together? Isn’t it just a stock Virtual earth control with a textbox. Well guess what? Pretty much it is, with a few tricks to make it work well and no crap put in. What this means is you too can offer localised Australian searching from your website. Want to get started right now? Go checkout the interactive SDK at live.com. Got some really good idea or running into problems with Virtual Earth – come talk to us at the MSDN forums. Have some really cool code to share? We just started a Virtual Earth code wiki at viavirtualearth.com.

So what are these tricks I speak of?

1) Basic lookup for what state you’re in. Just some hard coded JavaScript for performance. We have another version for the whole world but you add an extra AJAX call to work out your country and state/province, it slows it down a little.
2) Custom search box and Disambiguation box.
3) Support for controls in 3D mode
4) Full screen support. Resizes with your browser.
5) Firefox 2 support
6) Dispose the map on exit
7) Preloading message for VE JavaScript
8) Hide the message boxes
9) JavaScript optimisation (.js file is 4.11KB)
10) IIS compression (.htm file is 880 bytes, .js file is 1.59KB)
11) Kernel mode caching (hey they are static files – serve them up quick)

Where do I find out how to do these things? Visit the WIKI of course!

So what next for mygeoland.com? What would you like to see?
• Routeing?
• Traffic Cams?

We are trying to think of ways to get these features out there without slowing the whole thing down. Since we use the site all the time and hope now will too we want it to be super fast.

Working from home – 2 weeks in

BronwenWeeGo.jpgWell i’ve been working from home for 2 weeks now.  I must say that overall I am enjoying it.

I thought that not being on a bus for 2 hours every day would be a good thing…but i’ve realised it was my zone-out time to let my head clear of all thing work-related.  So I guess i just have to find something else to do between “finishing work” and “getting home” to do the same thing.

I’ve been racking up 45 hours a week without really realizing it which isn’t such a bad thing.  Means if i want a long lunch i got plenty of hours up my sleeve.

It’s really quiet though…miss the simple office sounds e.g the sound of ppl typing on a keyboard, so I thought i could record some office background sounds or something.  Of course the biggest thing is there’s not a physical person to turn around and chat to and you get sick of being at home…so after work you feel like going somewhere.

Obviously the great things are..you can sleep in and still start work by 8am, you can easily cook yourself anything you want for lunch, if you only want to work 40hrs a week…you have a lot more free time to do other stuff, makes it much easier to book things that need doing at the house where you need to be home to let them in.

Restful WebServices

BronwenWeeGo.jpgSo lately I’ve been converting some SOAP WebServices to Rest webservices.  There’s lots of papers on REST but atm there’s no real standards, just guidelines.  As far as i can tell, it’s just passing data using HTTP.

So if i have an existing webservice here: www.SoulSolutions.com.au/MyService.asmx with a method called GetPoints i’d want to call a method “GetPoints” in rest as www.SoulSolutions.com.au/MyService/Rest/GetPoints
and i can either pass the params in the query string or the request header/body.  I’ll go with header just for the fun of it.

Cause i just want to use the existing names, I’ll won’t user GET, PUT, and DELETE to determine the action of my method..but that’s just me being lazy

So these are the steps i took to build a restful web service…

1. Put all the common code into a class that both webservice and rest can call
2. Write a http handler called SoulSolutions.RestHandler
 Using reflection…
 It’ll load up the current assembly, and my common class.
 It grabs the name of the method from the request and validates it exists in the assembly
 Grab the parameter info and validate we have the right params and they’re the correct type etc
 Call the method and return the result…either as a text value or xml..
 
3. add the handler to my existing webservices project, and only pick up calls with a rest path

    <httpHandlers>
      <add verb="*" path="rest/*" type="SoulSolutions.RESTHandler, SoulSolutions" />
    </httpHandlers>

Improvements to this I’d like to make later…
Add some custom attributes to mark the logic classes as “Rest Classes” and mark the method within them as “Rest methods” for a couple of reasons…
1. We may split up the classes later and this will make it easy to find the valid ones
2. For the methods, we may only want to support a subset of methods for rest and we can add a methodname attribute if we want to rename what the user calls without changing the name of the underlying function.

Do some performance testing to see if i need to add some custom caching for the reflection

Later on i can put some logic to map a HTTP DELETE for a method Point to the function DeletePoint, GET to GetPoint, PUT to AddPoint etc

Good female developers and the Loch Ness monster…..

BronwenWeeGo.jpgHad to share this comment i got on my going-away card on Friday…

“A good female programmer.  Like Bigfoot and the Loch Ness monster, no reliable sightings existed until now – which means I can die happy”

Must say it definatly made me laugh, and then think how sad it is that people don’t think good female devs exist .  Pro’lly doesn’t help there aren’t a lot of females in the industry..just look at the stats from Tech ed.  They’re definatly out there though…maybe just need a few more in the spotlight so people are aware of them.  I know a couple of really good female devs…anyone else?

So much time saving ahead…

BronwenWeeGo.jpgI start a new contract working here on Monday, so today is my last day at SIS.  As i swiped my bus ticket this morning it made me think that one of the great things about working from home will be the fact i won’t spend at least 10hrs on buses every week and won’t have to spend $20.80 on bus tickets, and every 2nd ticket won’t get corrupted and need to be taken back.

Will we ever get rid of hand counted ballots?

BronwenWeeGo.jpgWas reading this article on E-voting in the US and made me think back to our recent state election in qld and how nice it’d be to just vote online or just use some sort of computer system at the polling booth.  Then i think about all the 70+ year olds that help out at the booths and think about most of the people I know that age and their level of pc competence (there are many exceptions, I know…but i’m generalising here) and try to imagine them dealing with pcs not working, people trying to find the any key etc

Study notes 70-553 Section 1 part e

Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace)
• Configuration class and ConfigurationManager class
• ConfigurationSettings class, ConfigurationElement class, ConfigurationElementCollection class, and ConfigurationElementProperty class
• Implement IConfigurationSectionHandler interface
• ConfigurationSection class, ConfigurationSectionCollection class, ConfigurationSectionGroup class, and ConfigurationSectionGroupCollection class
• Implement ISettingsProviderService interface
• Implement IApplicationSettingsProvider interface
• ConfigurationValidationBase class
• Implement IConfigurationSystem interface