very likely that the ending tag has some problems... try to delete that line and rewrite it again.... it may contain some invalid characters....
Main Topics
Browse All TopicsI am getting an xsltransform error below
The 'nflPlayer' start tag on line '1' does not match the end tag of 'nflPl'. Line 1, position 4092.
the 4092 position reeks of an encoding problem but I'm not sure how to fix it.
Here is my code:
Dim sw3 As New System.IO.StringWriter, xmlDoc3 As New XmlDocument
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
xmlDoc3.LoadXml(sw3.ToStri
it bombs on the last line. Any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The xml/xsl transformation is fine! I ran it in classic ASP and it runs.
It has something to do with the stringwriter xmltextwriter combination. The output document is cutting it off at 4096 (which you'll note is a factor of 1024 well known that the stupid stringwriter puts line breaks every 1024 characters)
So, I'm guessing the stringWriter is outputting some character after 4096 that the xmldoc is interpretting as the end of the string (note how it trimmed of the 'nflPlayer' node in mid word).
okie dokie... i see where you got the error.....
try this instead....
Dim sb As New System.Text.StringBuilder
Dim sw3 As New System.IO.StringWriter(sb)
, xmlDoc3 As New XmlDocument
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
xmlDoc3.LoadXml(sb.ToStrin
Sorry, no dice. Same error. Position 4092. BTW, I messed up. The error occurs on the just after the lines I showed above:
xmlDoc3.WriteTo(New XmlTextWriter(rawsoap.Soap
This line writes the doc to an output stream. hmmm, now that I look at it I think I see the error. It is utf8 encoded, but the stringWriter uses utf16 encoding. Hmmm. I guess if I could convert one to the other then I would be ok. Or maybe not.
arrgh, going on 24 hours and this problem won't go away. I can see the resultant xml document is well formed, but there is some character put in there at the 4097 (sorry I said 4092 earlier) position that is screwing things up.
When I write the xmldoc to the response.outputstream it sends along that character!
The client that receives the doc tries to load it, but it appears to end at the 4097 character. Even though I what I see in the debugger is a perfectly formed xml doc.
arrrrghhh!
probably there are something left in the buffer..... encoding should not be a problem here....
Dim sb As New System.Text.StringBuilder
Dim sw3 As New System.IO.StringWriter(sb)
, xmlDoc3 As New XmlDocument
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
sw3.Flush()
sw3.Close()
xmlDoc3.LoadXml(sb.ToStrin
how about this....
Dim sb As New System.Text.StringBuilder
Dim sw3 As New System.Xml.XmlTextWriter(s
, xmlDoc3 As New XmlDocument
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
sw3.Flush()
sw3.Close()
xmlDoc3.LoadXml(sb.ToStrin
i mean
Dim sb As New System.Text.StringBuilder
Dim sw3 As New System.Xml.XmlTextWriter(n
, xmlDoc3 As New XmlDocument
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
sw3.Flush()
sw3.Close()
xmlDoc3.LoadXml(sb.ToStrin
When I ran your code from post#1, I got the same error. When I ran your post#2 code I got 'System.InvalidCastExcepti
Anyway, you are focusing on the lines of code that work. The xml doc composes itself just fine!
I get the error on the line that comes just after the line your are debugging. Look at the last line of this code block. I get the error when I try to write the xmldoc to an ouput stream.
Dim sb As New System.Text.StringBuilder
Dim sw3 As New System.IO.StringWriter(New
Dim transform3 = New Xml.Xsl.XslTransform
transform3.Load(New XmlTextReader(HttpContext.
transform3.Transform(xmlDo
sw3.Flush()
sw3.Close()
xmlDoc3.LoadXml(sb.ToStrin
xmlDoc3.WriteTo(New XmlTextWriter(HttpContext.
Interesting. When I started sending a smaller xml document I started getting a new error. The error says:
This is an unexpected token. The expected token is 'EndElement'. Line 1, position 3071.
hmmm. I have no idea what is going on except that it appears that the document is about 3071 characters long, but when the soap consumer gets it it chokes because it can't find an 'endelement' token (whatever that is)
I read online about someone who got this error due to commas in their output document nodes, but he doesn't elaborate how he fixed it other than to say w/o the commas it worked (which isn't an option for me -- I can drop the comma between someone's first and last name because the consumer expects the document as is.
Here is the link to that thread:
http://www.error-bank.com/
Here are the source xml docs you requested.
'*************************
'source xml
'*************************
<?xml version="1.0" encoding="utf-16"?><conten
'*************************
'end source xml
'*************************
'*************************
'xsl document
'*************************
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.o
<xsl:output method="xml"
encoding="UTF8"
omit-xml-declaration="no"/
<xsl:template match="/">
<soap:Envelope>
<soap:Body>
<xsl:copy-of select="content/*[1]"/>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
'*************************
'end xsl document
'*************************
'*************************
'transformation result document (this is what I write to the ouput stream via xmlDoc3.WriteTo code)
'*************************
<?xml version="1.0" encoding="utf-16"?><soap:E
'*************************
'transformation result document
'*************************
Well, its taken over a week, but I have the answer, finally. I'm too worn down to be happy.
The problem had to do with xsl and namespace declarations. To make a long story short, I had the namespace for my webservice declared at too low a level. I moved it up to the top of the xsl document (in the xsl:stylesheet node) and everything worked.
I thought the consumer of my webservice couldn't see the xml document I was sending, or worse I wasn't sending a document at all, but that was incorrect.
I WAS sending a document, but the web service consumer couldn't recognize it because it was looking for nodes within my namespace see below:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.o
xmlns:soap="http://schemas
xmlns="urn:msdn-microsoft-
'my' namespace is the xmlns="urn:msdn-microsoft-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.o
xmlns:soap="http://schemas
Relatedly, I was using xsl:apply-templates so the AddResponse node was in a different template than AddResponse children nodes. That might have been a problem too, but I'm not sure about that part.
All I know for sure is that once I moved 'my' namespace up to the top level xsl:stylesheet node everything worked perfectly.
Business Accounts
Answer for Membership
by: testnPosted on 2005-03-12 at 10:47:47ID: 13525423
try to open yout xsl and xml in internet explorer and check whether u can open it in the browser. i not i mean that your doc has some problem...