Dana B wrote:
I am trying to get the values in FIELD2 and FIELD3 in the XML file
below using XSLT.
That's not XML - That's XML, wrapped up as a string, wrapped up in more
XML. Three layers of data! It's not only hard to parse, it actually
_means_ something quite different. Of course it might be intended to
mean the same thing after all, so don't take that difference too
seriously.
Now XSLT likes to see XML and it will (grudgingly) let you work with
strings inside XML. However it has no way to work with XML inside this
(3rd layer down).
If you want to work with this then you need to tree walk the outer XML
to get the strings, then pass this content to an XML parser! It's not
hard to do in a script language with a DOM (Java / JavaScript / Perl /
VB), although I'm not keen on the efficiency aspects.
As to doing it _within_ XSLT then I've never tried it, but it ought to
work fairly much the same, so long as you have an extension language
like JavaScript with access to a suitable DOM.
The real solution though is to not wrap it up in the first place. Is
this "inner" XML really well-formed XML ? Is it a well-formed fragment,
or is it also a well-formed XML document? (your's isn't - two root
elements) If it isn't, then any attempt to parse it is doomed. If it
is (even if it's a fragment) then why was it put in a CDATA section to
begin with ?
If this "inner" content _is_ XML, then there's no reason at all to wrap
it in a CDATA section. This is what namespacing is for, after all.