I have just used umb import to impornt (surprise surprise) a bibliography database into umbraco. This however is a problem as the database is incredibley inconsistent. This has lead to my current problem of trying to sort the nodes using <xsl:sort>. Im sorting cronologically by a field named date. However during the import and the state of the database i have some fields that conatain records like "2009may" or "2007 - 2009".
This proves a problem when sorting as these arent in the correct chronological positon that they should be in. Also I am wanting to break it up in sections (blocks of 10 years) which is also poses a problem due to said database. i have tried a substring query/text to take the first 4 characters (the year) and test it against a static value (e.g 1930). I have failed. Is there anyway i can split the field up to only take the year value and test that to make my categories or will i have to re-import that database?
You can do a lot with xslt, but to be honest, I'd clean up the source data and re-import. That will make all your xslt easier and also provide a good basis moving forward. The old rule of 'garbage in, garbage out' is certainly the case here and is a common problem when importing legacy data.
BTW, you might want to have two date fields if you need date ranges. Possibly use a real date field, or a strictly formatted textstring (which you can validate with regex on the docType for any new items that are added once the data is in umbraco).
It may be easier to re-import the database, but hows about a function inline in xslt (c#, vb, js) that would clean the dates and return either only the numbers or months?
How effective it will be depends on how different the stored date values are, but I imagine getting either only numbers or the month as text wouldn't be too difficult. You could also check it the year number two digits (e.g. 07) or 4 digits (e.g. 1997) and adjust accordingly.
I only realised how messy the original database was AFTER the import (i had a huge problem with that too, but that was of my own stupidity). I shall attempt to tidy up the database.
XSLT string manipulation
Howdy All,
I have just used umb import to impornt (surprise surprise) a bibliography database into umbraco. This however is a problem as the database is incredibley inconsistent. This has lead to my current problem of trying to sort the nodes using <xsl:sort>. Im sorting cronologically by a field named date. However during the import and the state of the database i have some fields that conatain records like "2009may" or "2007 - 2009".
This proves a problem when sorting as these arent in the correct chronological positon that they should be in. Also I am wanting to break it up in sections (blocks of 10 years) which is also poses a problem due to said database. i have tried a substring query/text to take the first 4 characters (the year) and test it against a static value (e.g 1930). I have failed. Is there anyway i can split the field up to only take the year value and test that to make my categories or will i have to re-import that database?
my xsl is as follows
Cheers
Alec
Apologies there is still some testing code in the sample i provided.
You can do a lot with xslt, but to be honest, I'd clean up the source data and re-import. That will make all your xslt easier and also provide a good basis moving forward. The old rule of 'garbage in, garbage out' is certainly the case here and is a common problem when importing legacy data.
BTW, you might want to have two date fields if you need date ranges. Possibly use a real date field, or a strictly formatted textstring (which you can validate with regex on the docType for any new items that are added once the data is in umbraco).
cheers,
doug.
It may be easier to re-import the database, but hows about a function inline in xslt (c#, vb, js) that would clean the dates and return either only the numbers or months?
How effective it will be depends on how different the stored date values are, but I imagine getting either only numbers or the month as text wouldn't be too difficult. You could also check it the year number two digits (e.g. 07) or 4 digits (e.g. 1997) and adjust accordingly.
+1 for "garbage in, garbage out" !
Thanks for the feedback.
I only realised how messy the original database was AFTER the import (i had a huge problem with that too, but that was of my own stupidity). I shall attempt to tidy up the database.
Thanks
Alec
is working on a reply...