Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


exclude-result-prefixes not working on server side transformation

From: "Keith Chadwick" <webmaster-nospam@--------------.--->
To: 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() =
&gt; " & StartPage & " and position() &lt; " & 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.&nbsp; But the server side transform is =
not=20
removing the sql&nbsp;namespace.&nbsp; Code is as follows</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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 =
"&lt;?xml=20
version=3D'1.0'?&gt;"<BR>sSQL =3D "&lt;ROOT=20
xmlns:sql=3D""urn:schemas-microsoft-com:xml-sql""&gt;"<BR>sSQL +=3D=20
"&lt;contacts&gt;"<BR>sSQL +=3D "&lt;sql:query&gt;Select * from contacts =
for xml=20
auto&lt;/sql:query&gt;"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>sSQL+=3D"&lt;/contacts&gt;"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>sSQL+=3D"&lt;/ROOT&gt;"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT>&nbsp;</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>&nbsp;</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 =
"&lt;?xml=20
version=3D'1.0'?&gt;"<BR>xmlstr +=3D "&lt;xsl:stylesheet =
version=3D""1.0""&nbsp;=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"" &gt;"<BR>xmlstr =
+=3D=20
"&lt;xsl:output method=3D""xml"" /&gt;"<BR>xmlstr +=3D "&lt;xsl:template =

match=3D""/""&gt;"<BR>xmlstr +=3D "&lt;ROOT&gt;"<BR>xmlstr +=3D=20
"&lt;contacts&gt;"<BR>xmlstr +=3D "&lt;xsl:for-each=20
select=3D""/ROOT/contacts/contact[position() &amp;gt; " &amp; StartPage =
&amp; "=20
and position() &amp;lt; " &amp; EndPage &amp; "]""&gt;"<BR>xmlstr +=3D=20
"&lt;xsl:copy-of select=3D"".""/&gt;"<BR>xmlstr +=3D=20
"&lt;/xsl:for-each&gt;"<BR>xmlstr +=3D "&lt;/contacts&gt;"<BR>xmlstr =
+=3D=20
"&lt;/ROOT&gt;"<BR>xmlstr +=3D "&lt;/xsl:template&gt;"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>xmlstr +=3D=20
"&lt;/xsl:stylesheet&gt;"</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Below is the resulting xml</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 size=3D2>&lt;?xml =
version=3D"1.0"=20
encoding=3D"utf-8"=20
?&gt;&nbsp;<BR>&lt;ROOT&gt;<BR>&lt;contacts&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;contact id=3D"738" name=3D"B-margaret, B-french" =
organization=3D"HRDC"=20
xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" =
/&gt;&nbsp;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;contact id=3D"698" name=3D"B-mauge, B-annette" =
organization=3D"Health Canada"=20
xmlns:sql=3D"urn:schemas-microsoft-com:xml-sql" /&gt; =
<BR>&nbsp;&nbsp;&nbsp;=20
.....</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080=20
size=3D2>&lt;/contacts&gt;</FONT></DIV>
<DIV><FONT face=3D"Courier New" color=3D#000080 =
size=3D2>&lt;/ROOT&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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!&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any thoughts</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0041_01C4DC63.6B4F03F0--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent