Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: exclude-result-prefixes not working on server side transformation exclude-result-prefixes not working on server side transformationTo: NULL Date: 12/7/2004 1:48:00 PM This is a multi-part message in MIME format.
------=_NextPart_000_0041_01C4DC63.6B4F03F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Have a server side transformation that transforms data returns via =
SqlXMLCommand. But the server side transform is not removing the sql =
namespace. Code is as follows
' Fetch the data
Dim xmlrsltdoc as new xmldocument
Dim sSQL as string
sSQL =3D "<?xml version=3D'1.0'?>"
sSQL =3D "<ROOT xmlns:sql=3D""urn:schemas-microsoft-com:xml-sql"">"
sSQL +=3D "<contacts>"
sSQL +=3D "<sql:query>Select * from contacts for xml auto</sql:query>"
sSQL+=3D"</contacts>"
sSQL+=3D"</ROOT>"
sqlCmd.CommandType =3D SqlXmlCommandType.Template
sqlCmd.CommandText =3D sSQL
xmlrsltdoc.Load(sqlCmd.ExecuteXmlReader())
' Build the template
dm xmlstr as string
xmlstr =3D "<?xml version=3D'1.0'?>"
xmlstr +=3D "<xsl:stylesheet version=3D""1.0"" =
xmlns:xsl=3D""http://www.w3.org/1999/XSL/Transform"" =
xmlns:sql=3D""urn:schemas-microsoft-com:xml-sql"" "
xmlstr +=3D " exclude-result-prefixes=3D""sql"" >"
xmlstr +=3D "<xsl:output method=3D""xml"" />"
xmlstr +=3D "<xsl:template match=3D""/"">"
xmlstr +=3D "<ROOT>"
xmlstr +=3D "<contacts>"
xmlstr +=3D "<xsl:for-each select=3D""/ROOT/contacts/contact[position() =
> " & StartPage & " and position() < " & EndPage & "]"">"
xmlstr +=3D "<xsl:copy-of select=3D"".""/>"
xmlstr +=3D "</xsl:for-each>"
xmlstr +=3D "</contacts>"
xmlstr +=3D "</ROOT>"
xmlstr +=3D "</xsl:template>"
xmlstr +=3D "</xsl:stylesheet>"
Dim sr As New StringReader(xmlstr)
Dim tr As XmlTextReader =3D New XmlTextReader(sr)
Dim xs As XslTransform =3D New XslTransform
xs.Load(tr, Nothing, Nothing)
Dim sw As StringWriter =3D New StringWriter
xs.Transform(xmlrsltdoc, Nothing, sw, Nothing)
xmlrsltdoc.LoadXml(sw.ToString)
Below is the resulting xml
<?xml version=3D"1.0" encoding=3D"utf-8" ?>=20
<ROOT>
<contacts>
<contact id=3D"738" name=3D"B-margaret, B-french" =
organization=3D"HRDC" xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" /> =
<contact id=3D"698" name=3D"B-mauge, B-annette" =
organization=3D"Health Canada" =
xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" />=20
.....
</contacts>
</ROOT>
As you can see the sql prefix urn is still present even though the =
stylesheet explicitly stated to exclude the prefix sql! If I do not =
include the sql namespace in the transformation the transform craps out?
Any thoughts
Cheers
Keith
------=_NextPart_000_0041_01C4DC63.6B4F03F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Have a server side transformation that =
transforms=20
data returns via SqlXMLCommand. But the server side transform is =
not=20
removing the sql namespace. Code is as follows</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>' Fetch the =
data</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>Dim xmlrsltdoc =
as new=20
xmldocument</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>Dim sSQL as=20
string</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>sSQL =3D =
"<?xml=20
version=3D'1.0'?>"<BR>sSQL =3D "<ROOT=20
xmlns:sql=3D""urn:schemas-microsoft-com:xml-sql"">"<BR>sSQL +=3D=20
"<contacts>"<BR>sSQL +=3D "<sql:query>Select * from contacts =
for xml=20
auto</sql:query>"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>sSQL+=3D"</contacts>"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>sSQL+=3D"</ROOT>"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT> </DIV><FONT=20
face=3D"Courier New" color=3D#000080 size=3D2>sqlCmd.CommandType =3D=20
SqlXmlCommandType.Template<BR>sqlCmd.CommandText =3D=20
sSQL<BR>xmlrsltdoc.Load(sqlCmd.ExecuteXmlReader())</FONT>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>' Build the=20
template</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>dm xmlstr as=20
string</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>xmlstr =3D =
"<?xml=20
version=3D'1.0'?>"<BR>xmlstr +=3D "<xsl:stylesheet =
version=3D""1.0"" =20
xmlns:xsl=3D""</FONT><A =
href=3D"http://www.w3.org/1999/XSL/Transform"><FONT=20
face=3D"Courier New" color=3D#000080=20
size=3D2>http://www.w3.org/1999/XSL/Transform</FONT></A><FONT =
face=3D"Courier New"=20
color=3D#000080 size=3D2>"" =
xmlns:sql=3D""urn:schemas-microsoft-com:xml-sql""=20
"<BR>xmlstr +=3D " exclude-result-prefixes=3D""sql"" >"<BR>xmlstr =
+=3D=20
"<xsl:output method=3D""xml"" />"<BR>xmlstr +=3D "<xsl:template =
match=3D""/"">"<BR>xmlstr +=3D "<ROOT>"<BR>xmlstr +=3D=20
"<contacts>"<BR>xmlstr +=3D "<xsl:for-each=20
select=3D""/ROOT/contacts/contact[position() &gt; " & StartPage =
& "=20
and position() &lt; " & EndPage & "]"">"<BR>xmlstr +=3D=20
"<xsl:copy-of select=3D"".""/>"<BR>xmlstr +=3D=20
"</xsl:for-each>"<BR>xmlstr +=3D "</contacts>"<BR>xmlstr =
+=3D=20
"</ROOT>"<BR>xmlstr +=3D "</xsl:template>"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>xmlstr +=3D=20
"</xsl:stylesheet>"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>Dim sr As New=20
StringReader(xmlstr)<BR>Dim tr As XmlTextReader =3D New =
XmlTextReader(sr)<BR>Dim=20
xs As XslTransform =3D New XslTransform<BR>xs.Load(tr, Nothing,=20
Nothing)</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>Dim sw As =
StringWriter =3D New=20
StringWriter<BR>xs.Transform(xmlrsltdoc, Nothing, sw, =
Nothing)</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>xmlrsltdoc.LoadXml(sw.ToString)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Below is the resulting xml</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2><?xml =
version=3D"1.0"=20
encoding=3D"utf-8"=20
?> <BR><ROOT><BR><contacts><BR> =20
<contact id=3D"738" name=3D"B-margaret, B-french" =
organization=3D"HRDC"=20
xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" =
/> <BR> =20
<contact id=3D"698" name=3D"B-mauge, B-annette" =
organization=3D"Health Canada"=20
xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" /> =
<BR> =20
.....</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2></contacts></FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></ROOT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>As you can see the sql prefix urn is =
still present=20
even though the stylesheet explicitly stated to exclude the prefix =
sql! If=20
I do not include the sql namespace in the transformation the transform =
craps=20
out?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any thoughts</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Cheers</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Keith</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0041_01C4DC63.6B4F03F0--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
