XSLT file does not seem to be processing XML file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive missed something obvious - Im sure of it.
However given the following XML File
<div style="background-color:white; color:black
<pre><span style="color:blue <?<span style="color:#a31515 xml <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black " <span style="color:red encoding<span style="color:blue =<span style="color:black "<span style="color:blue UTF-8<span style="color:black " <span style="color:blue ?>

<span style="color:blue <<span style="color:#a31515 GovTalkMessage <span style="color:red xsi:schemaLocation<span style="color:blue =<span style="color:black "<span style="color:blue http://www.govtalk.gov.uk/CM/envelope http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch-v2-0.xsd<span style="color:black " <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://www.govtalk.gov.uk/CM/envelope<span style="color:black " <span style="color:red xmlns:dsig<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2000/09/xmldsig#<span style="color:black " <span style="color:red xmlns:gt<span style="color:blue =<span style="color:black "<span style="color:blue http://www.govtalk.gov.uk/schemas/govtalk/core<span style="color:black " <span style="color:red xmlns:xsi<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema-instance<span style="color:black " <span style="color:blue >

<span style="color:blue <<span style="color:#a31515 EnvelopeVersion<span style="color:blue >1.0<span style="color:blue </<span style="color:#a31515 EnvelopeVersion<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Header<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 MessageDetails<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Class<span style="color:blue >NumberSearch<span style="color:blue </<span style="color:#a31515 Class<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Qualifier<span style="color:blue >error<span style="color:blue </<span style="color:#a31515 Qualifier<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 TransactionID<span style="color:blue >634276991342983857<span style="color:blue </<span style="color:#a31515 TransactionID<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 GatewayTimestamp<span style="color:blue >2010-12-11T21:19:06-00:00<span style="color:blue </<span style="color:#a31515 GatewayTimestamp<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 MessageDetails<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 SenderDetails<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 IDAuthentication<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 SenderID<span style="color:blue >UserID<span style="color:blue </<span style="color:#a31515 SenderID<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Authentication<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Method<span style="color:blue >CHMD5<span style="color:blue </<span style="color:#a31515 Method<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Value<span style="color:blue ><span style="color:blue </<span style="color:#a31515 Value<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 Authentication<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 IDAuthentication<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 SenderDetails<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 Header<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 GovTalkDetails<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Keys<span style="color:blue />

<span style="color:blue <<span style="color:#a31515 GovTalkErrors<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Error<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 RaisedBy<span style="color:blue >NumberSearch<span style="color:blue </<span style="color:#a31515 RaisedBy<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Number<span style="color:blue >600<span style="color:blue </<span style="color:#a31515 Number<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Type<span style="color:blue >fatal<span style="color:blue </<span style="color:#a31515 Type<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Text<span style="color:blue >Company does not exist on the selected index<span style="color:blue </<span style="color:#a31515 Text<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Location<span style="color:blue ><span style="color:blue </<span style="color:#a31515 Location<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 Error<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 GovTalkErrors<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 GovTalkDetails<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Body<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 Body<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 GovTalkMessage<span style="color:blue >



[/code]

I need to transfer that into the following
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 GovTalkStatus<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Status<span style="color:blue >error<span style="color:blue </<span style="color:#a31515 Status<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 GovTalkStatus<span style="color:blue >



[/code]

and this is the current XSL file
<div style="background-color:white; color:black
<pre><span style="color:blue <?<span style="color:#a31515 xml <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black "<span style="color:blue ?>

<span style="color:blue <<span style="color:#a31515 xsl<span style="color:blue :<span style="color:#a31515 stylesheet <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black " <span style="color:red xmlns:xsl<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/1999/XSL/Transform<span style="color:black "<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 xsl<span style="color:blue :<span style="color:#a31515 template <span style="color:red match<span style="color:blue =<span style="color:black "<span style="color:blue /<span style="color:black "<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 GovTalkStatus <span style="color:red xmlns:xsi<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema-instance<span style="color:black "

<span style="color:red xmlns:xsd<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema<span style="color:black "<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Status<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:blue<span style="color:black "<span style="color:blue ><<span style="color:blue </<span style="color:#a31515 span<span style="color:blue ><span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:#2b91af<span style="color:black "<span style="color:blue >xsl:value-of<span style="color:blue </<span style="color:#a31515 span<span style="color:blue ><span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:blue<span style="color:black "<span style="color:blue > <span style="color:blue </<span style="color:#a31515 span<span style="color:blue ><span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:red<span style="color:black "<span style="color:blue >select<span style="color:blue </<span style="color:#a31515 span<span style="color:blue ><span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:blue<span style="color:black "<span style="color:blue >=<span style="color:blue </<span style="color:#a31515 span<span style="color:blue >"<span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:blue<span style="color:black "<span style="color:blue >GovTalkMessage/Header/MessageDetails/Qualifier<span style="color:blue </<span style="color:#a31515 span<span style="color:blue >"<span style="color:blue <<span style="color:#a31515 span <span style="color:red style<span style="color:blue =<span style="color:black "<span style="color:blue color:blue<span style="color:black "<span style="color:blue >/><span style="color:blue </<span style="color:#a31515 span<span style="color:blue ><span style="color:blue <<span style="color:#a31515 br<span style="color:blue /> <span style="color:blue </<span style="color:#a31515 Status<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 GovTalkStatus<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 xsl<span style="color:blue :<span style="color:#a31515 template<span style="color:blue >

<span style="color:blue </<span style="color:#a31515 xsl<span style="color:blue :<span style="color:#a31515 stylesheet<span style="color:blue >

[/code]

What I am getting however is
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 GovTalkStatus<span style="color:blue >

<span style="color:blue <<span style="color:#a31515 Status<span style="color:blue />

<span style="color:blue </<span style="color:#a31515 GovTalkStatus<span style="color:blue >



[/code]

This is sent eventually so a serialize object so that I can deserialize it and that code is
<div style="background-color:white; color:black
<pre> <span style="color:blue try

{

xslt = <span style="color:blue new XslCompiledTransform();



<span style="color:green // retrieve the template and load into the Transformer

xslTemplate = Toolbox.GetRequest(<span style="color:#a31515 "GovTalkStatus.xsl");

xslTemplate.Seek(0, SeekOrigin.Begin);

templateReader = XmlReader.Create(xslTemplate);

xslt.Load(templateReader);



<span style="color:green // load the message

xmlDocument = <span style="color:blue new XmlDocument();

xmlDocument.LoadXml(GovTalkMessage);



resultStream = <span style="color:blue new MemoryStream();

writer = <span style="color:blue new XmlTextWriter(resultStream, Encoding.ASCII);

xslt.Transform(xmlDocument, writer);



resultStream.Seek(0, SeekOrigin.Begin);

statusXML = Toolbox.ConvertByteArrayToString(resultStream.ToArray());



<span style="color:green // deserialize the new XML document



encoder = <span style="color:blue new ASCIIEncoding();

ms = <span style="color:blue new MemoryStream(encoder.GetBytes(statusXML));

serializer = <span style="color:blue new XmlSerializer(<span style="color:blue typeof(GovTalkStatus));

xmlTextWriter = <span style="color:blue new XmlTextWriter(ms, Encoding.ASCII);

messageStatus = (GovTalkStatus)serializer.Deserialize(ms);







}

<span style="color:blue catch(System.Exception ex)

{

<span style="color:blue throw;

}

<span style="color:blue finally

{

ms.Dispose();

serializer = <span style="color:blue null;

xmlTextWriter = <span style="color:blue null;



}

[/code]

Anyone know what painfully obvious thing I am missing?


View the full article
 
Back
Top