A legacy XML feed we want to consume (it's coupled to a specific database and has no XSD) emits "Y" or "N" as truth values. We are creating an XSD and auto-generating C# classes from this, with some transforms to make things neater.
So if I have fields like <IsFed>Y</IsFed> on an object, how can I transform these using XSLT so something that would validate against xsd:boolean?
I'm interested in two approaches:
- Explicitly listing each field to be transformed
- Automatically detecting every such yes/no field (I realise this could have errors)
Sample XML might look like this:
<Animal type="hamster">
<IsFed>Y</IsFed>
<Name>Gerald</Name>
</Animal>
<Animal type="cow">
<IsFed>N</IsFed>
<Name>acv4445-7</Name>
</Animal>
And it should come out like:
<Animal type="hamster">
<IsFed>true</IsFed>
<Name>Gerald</Name>
</Animal>
<Animal type="cow">
<IsFed>false</IsFed>
<Name>acv4445-7</Name>
</Animal>