Process XML from inside XML
-
I am having an issue. I need to perform an xslt on an xml document however the document contains xml encoded inside the xml (see sample below). I need to know how to pull out the inner xml so I can parse it from inside an xslt transform. Any help is greatly appreciated. (code) (/code)
-
I am having an issue. I need to perform an xslt on an xml document however the document contains xml encoded inside the xml (see sample below). I need to know how to pull out the inner xml so I can parse it from inside an xslt transform. Any help is greatly appreciated. (code) (/code)
Hi, As it appears here, your xml is not valid. The "<" character cannot appear within an atribute value, unless you escape it as < Also you have " charaters embedded within an attribute value that uses the same " character to enclose the attribute value, you could escape the inner quotes as " You need to fix the xml before you can look at the xslt. Are you able to change the xml structure? If the attribute must contain xml, then you will have to escape the appropriate characters, after that you will be able to use the value-of element to retrieve the escaped xml. At that point, I guess you would need to 'un-escape' it. Sounds complicated... Good Luck, Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Hi, As it appears here, your xml is not valid. The "<" character cannot appear within an atribute value, unless you escape it as < Also you have " charaters embedded within an attribute value that uses the same " character to enclose the attribute value, you could escape the inner quotes as " You need to fix the xml before you can look at the xslt. Are you able to change the xml structure? If the attribute must contain xml, then you will have to escape the appropriate characters, after that you will be able to use the value-of element to retrieve the escaped xml. At that point, I guess you would need to 'un-escape' it. Sounds complicated... Good Luck, Cheers Phil Hobgen barbari.co.uk Southampton, UK
Phil (barbari) wrote: As it appears here, your xml is not valid. Didn't he write "the document contains xml encoded inside the xml". I'd guess it is escaped. But my English is self-thought ( in computer terminology), so word "encode" has only one meaning to me ... :) Phil (barbari) wrote: You need to fix the xml before you can look at the xslt. Phil (barbari) wrote: Sounds complicated... agree. I think it's plain bad xml structure. I'd move "inner" xml out of attribute. Attributes are not meant to contain hierarchical things... Use them for atomic data seems the best way to me. I'd move that xml to CDATA element inside current
variable
or what element is was. other ideas? David Never forget: "Stay kul and happy" (I.A.) -
I am having an issue. I need to perform an xslt on an xml document however the document contains xml encoded inside the xml (see sample below). I need to know how to pull out the inner xml so I can parse it from inside an xslt transform. Any help is greatly appreciated. (code) (/code)
see http://www.codeproject.com/script/comments/forums.asp?forumid=3421&select=1055340&df=100#xx1055340xx[^] Never forget: "Stay kul and happy" (I.A.)
-
Phil (barbari) wrote: As it appears here, your xml is not valid. Didn't he write "the document contains xml encoded inside the xml". I'd guess it is escaped. But my English is self-thought ( in computer terminology), so word "encode" has only one meaning to me ... :) Phil (barbari) wrote: You need to fix the xml before you can look at the xslt. Phil (barbari) wrote: Sounds complicated... agree. I think it's plain bad xml structure. I'd move "inner" xml out of attribute. Attributes are not meant to contain hierarchical things... Use them for atomic data seems the best way to me. I'd move that xml to CDATA element inside current
variable
or what element is was. other ideas? David Never forget: "Stay kul and happy" (I.A.)Hi, dnh wrote: Didn't he write "the document contains xml encoded inside the xml". I'd guess it is escaped. But my English is self-thought ( in computer terminology), so word "encode" has only one meaning to me ... You're probably right. :doh: I must admit to having been somewhat surprised to see xml like that. dnh wrote: other ideas? Not really. If the xml structure can be changed then a CDATA section sounds like just the right approach. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
I am having an issue. I need to perform an xslt on an xml document however the document contains xml encoded inside the xml (see sample below). I need to know how to pull out the inner xml so I can parse it from inside an xslt transform. Any help is greatly appreciated. (code) (/code)
Hi, Having a bit more of a think.... If you are working to a schema, and the format of the xml currently in
Value
is not clearly definable then, if you can change the schema, you could just use anxs:any
element (withmaxOccurs="unbounded"
) to define the nested xml but place it within theVariable
element. If there is no schema then you could just move the xml as above anyway, with no worries about schema changes. So there is no need for a CDATA section really. Of course in either case you may be exchanging this data with someone else, who you may or may not be able to get agreement with :) If you can't move the 'encoded' xml, and presuming it is all properly escaped, I think maybe the place to start is to select theValue
attribute into avariable
. This would contain a tree fragment that you can perform all the usual xslt stuff on. For instance you could set up atemplate
with amatch
ofALL_RESULTS
, you could call the template withapply-templates
with aselect
on the variable you have created. If that doesn't work then perhaps you could pass the variable into aparam
of thetemplate
and process it that way. I dont think it matters that the source for the variable is text containing < as opposed to < etc, the xslt processor can't tell the diference, I think :-D Sorry I dont have time to test out the theory - I would be interested to hear how you get this to work.. Cheers Phil Hobgen barbari.co.uk Southampton, UK