473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Beginners problem with namespace/schema?

Hi,
I have used xsl to transform xml from sqlserver in and it works fine
now i have a webservice that uses a dataset to get the data and return it as
xml
like the code below

<WebMethod()> _
Public Function ReturnEarnedValues() As XmlDocument
Dim MyStream As New IO.StringWriter
Dim XD As New XmlDocument
OleDbDataAdapter1.Fill(MyDataSet1)
MyDataSet1.WriteXml(MyStream)
XD.LoadXml(MyStream.ToString)
Return XD
End Function

Now the problem, my XSL does not work anymore and i think it has to do with
the xmlns tag and "mydataset" because nothing is transformed anymore. So how
should i write the xml or the xsl to fix this problem?

The xmlfile returned look like this
<?xml version="1.0" encoding="utf-8"?>
<MyDataSet xmlns="http://ixx.se/MyDataSet.xsd">
<Table>
<Omsatt>601</Omsatt>
</Table>
</MyDataSet>

and the XSL file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes" method="html" />
<xsl:template match="/">
<html>
<head>
<style type="text/css">
.blackText {font-family:arial;color:#000000;}
.largeYellowText {font-family:arial;font-size:18pt;
color:#ffff00;}
.largeBlackText {font-family:arial;font-size:10pt;
color:#000000;}
.borders {border-left:1px solid #000000;
border-right:1px solid #000000;
border-top:1px solid #000000;
border-bottom:1px solid #000000;}
</style>
</head>
<body bgcolor="#ffffff">
<span class="largeBlackText">
<b>Scala:</b>
</span>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="Table">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="50%"
background="http://cougar/_layouts/images/partgrad.gif"><b>
<font face="Verdana" size="1">Omsatt idag <xsl:value-of
select="Omsatt"/></font></b></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

Am I doing it wrong with the dataset or can I change the xsl or xml in some
way so it does not refer to the schema in the xmlfile like "standalone=yes"
or something?

Best regards
Fredrik
Nov 12 '05 #1
6 2169


Fredrik Nelson wrote:
I have used xsl to transform xml from sqlserver in and it works fine
now i have a webservice that uses a dataset to get the data and return it as
xml
like the code below

<WebMethod()> _
Public Function ReturnEarnedValues() As XmlDocument
Dim MyStream As New IO.StringWriter
Dim XD As New XmlDocument
OleDbDataAdapter1.Fill(MyDataSet1)
MyDataSet1.WriteXml(MyStream)
XD.LoadXml(MyStream.ToString)
Return XD
End Function

Now the problem, my XSL does not work anymore and i think it has to do with
the xmlns tag and "mydataset" because nothing is transformed anymore. So how
should i write the xml or the xsl to fix this problem?

The xmlfile returned look like this
<?xml version="1.0" encoding="utf-8"?>
<MyDataSet xmlns="http://ixx.se/MyDataSet.xsd">
<Table>
<Omsatt>601</Omsatt>
</Table>
</MyDataSet>

and the XSL file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
You need to declare
xmlns:somePrefix="http://ixx.se/MyDataSet.xsd"
here in the stylesheet and then use
<xsl:template match="Table">


<xsl:template match="somePrefix:Table">
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2
Thanks!!
Worked great

"Martin Honnen" <Ma***********@t-online.de> skrev i meddelandet
news:Ox**************@tk2msftngp13.phx.gbl...


Fredrik Nelson wrote:
I have used xsl to transform xml from sqlserver in and it works fine
now i have a webservice that uses a dataset to get the data and return it as xml
like the code below

<WebMethod()> _
Public Function ReturnEarnedValues() As XmlDocument
Dim MyStream As New IO.StringWriter
Dim XD As New XmlDocument
OleDbDataAdapter1.Fill(MyDataSet1)
MyDataSet1.WriteXml(MyStream)
XD.LoadXml(MyStream.ToString)
Return XD
End Function

Now the problem, my XSL does not work anymore and i think it has to do with the xmlns tag and "mydataset" because nothing is transformed anymore. So how should i write the xml or the xsl to fix this problem?

The xmlfile returned look like this
<?xml version="1.0" encoding="utf-8"?>
<MyDataSet xmlns="http://ixx.se/MyDataSet.xsd">
<Table>
<Omsatt>601</Omsatt>
</Table>
</MyDataSet>

and the XSL file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


You need to declare
xmlns:somePrefix="http://ixx.se/MyDataSet.xsd"
here in the stylesheet and then use
<xsl:template match="Table">


<xsl:template match="somePrefix:Table">
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3
Actually i now got one more question

concidering the previous question if i now want to put the instruction
"xml-stylesheet" tag into the resulting xmlfile as well
i tried the following code but no matter how i change the order and so on i
cant get the instruction stylsheet instruction in the beginning of the
document, any ideas?

Dim newPI As XmlProcessingInstruction
Dim PItext As String = "type='text/xsl' href='dataset.xslt'"
newPI = XD.CreateProcessingInstruction("xml-stylesheet", PItext)
XD.LoadXml(MyStream.ToString)
XD.AppendChild(newPI)

"Martin Honnen" <Ma***********@t-online.de> skrev i meddelandet
news:Ox**************@tk2msftngp13.phx.gbl...


Fredrik Nelson wrote:
I have used xsl to transform xml from sqlserver in and it works fine
now i have a webservice that uses a dataset to get the data and return it as xml
like the code below

<WebMethod()> _
Public Function ReturnEarnedValues() As XmlDocument
Dim MyStream As New IO.StringWriter
Dim XD As New XmlDocument
OleDbDataAdapter1.Fill(MyDataSet1)
MyDataSet1.WriteXml(MyStream)
XD.LoadXml(MyStream.ToString)
Return XD
End Function

Now the problem, my XSL does not work anymore and i think it has to do with the xmlns tag and "mydataset" because nothing is transformed anymore. So how should i write the xml or the xsl to fix this problem?

The xmlfile returned look like this
<?xml version="1.0" encoding="utf-8"?>
<MyDataSet xmlns="http://ixx.se/MyDataSet.xsd">
<Table>
<Omsatt>601</Omsatt>
</Table>
</MyDataSet>

and the XSL file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


You need to declare
xmlns:somePrefix="http://ixx.se/MyDataSet.xsd"
here in the stylesheet and then use
<xsl:template match="Table">


<xsl:template match="somePrefix:Table">
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #4


Fredrik Nelson wrote:

concidering the previous question if i now want to put the instruction
"xml-stylesheet" tag into the resulting xmlfile as well
i tried the following code but no matter how i change the order and so on i
cant get the instruction stylsheet instruction in the beginning of the
document, any ideas?

Dim newPI As XmlProcessingInstruction
Dim PItext As String = "type='text/xsl' href='dataset.xslt'"
newPI = XD.CreateProcessingInstruction("xml-stylesheet", PItext)
XD.LoadXml(MyStream.ToString)
XD.AppendChild(newPI)


You can produce a processing instruction with XSLT:
<xsl:processing-instruction
name="xml-stylesheet">type="text/xsl"
href="dataset.xslt"</xsl:processing-instruction>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #5
Hi Martin

Forgive me for my ignorance, but please be patient..

I dont understand where/how to put the suggested code. it does not work in
the xml file
and putting it in xsl does not make scence to me because i never get that
file, right? or am i missing something
obvious here?

The case is like this: I want to point a browser to a url and then retrive a
nice xmldocument, including stylesheet processing command so it is
transformed and nicely shown in the browser. Maybe i shouldnt try it this
way?

Best regards
Fredrik Nelson
"Martin Honnen" <Ma***********@t-online.de> skrev i meddelandet
news:%2***************@TK2MSFTNGP11.phx.gbl...


Fredrik Nelson wrote:

concidering the previous question if i now want to put the instruction
"xml-stylesheet" tag into the resulting xmlfile as well
i tried the following code but no matter how i change the order and so on i cant get the instruction stylsheet instruction in the beginning of the
document, any ideas?

Dim newPI As XmlProcessingInstruction
Dim PItext As String = "type='text/xsl' href='dataset.xslt'"
newPI = XD.CreateProcessingInstruction("xml-stylesheet", PItext)
XD.LoadXml(MyStream.ToString)
XD.AppendChild(newPI)


You can produce a processing instruction with XSLT:
<xsl:processing-instruction
name="xml-stylesheet">type="text/xsl"
href="dataset.xslt"</xsl:processing-instruction>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #6


Fredrik Nelson wrote:

I dont understand where/how to put the suggested code. it does not work in
the xml file
and putting it in xsl does not make scence to me because i never get that
file, right? or am i missing something
obvious here?

The case is like this: I want to point a browser to a url and then retrive a
nice xmldocument, including stylesheet processing command so it is
transformed and nicely shown in the browser. Maybe i shouldnt try it this
way?


I assumed you would do some XSLT transformation on the server.
Looking at your original post you had

Dim MyStream As New IO.StringWriter
Dim XD As New XmlDocument
OleDbDataAdapter1.Fill(MyDataSet1)
MyDataSet1.WriteXml(MyStream)
XD.LoadXml(MyStream.ToString)
Return XD

if you want to insert a processing instruction into the XD XmlDocument
before returning it you need to use the DOM to create a processing
instruction node and insert it into the document. You are using VB but I
am much better with C# so what follows is a C# snippet
XmlProcessingInstruction pi =
XD.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\"
href=\"yourStylesheet.xsl\"");
XD.InsertBefore(pi, XD.DocumentElement);

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stanimir Stamenkov | last post by:
I'm trying to find out if it is permissible to include a schema document with absent target namespace to a schema with specified target namespace, and if it is, what are the rules to resolve the...
2
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
8
by: Marc | last post by:
Hi! I'm calling a web service using C# and a wrapper class generated by wsdl tool. The web service specification contains some nillable parameters which types are Value Types in .NET (long, int,...
2
by: Carmit | last post by:
Hi, I'm trying to build a proxy for this webservice: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/EndTransactionLLSRQ.wsdl I'm getting the following error: Error: Unable to import...
1
by: leslie_tighe | last post by:
Hello, I have webservice created with Axis 1.2.1 and that I am trying to consuming in .NET (VB) using the Microsoft provided tools. While I am able to consume methods on the service that return...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
3
by: Jon | last post by:
I have an xml document like so... <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:ng="http://newsgator.com/schema/extensions"> <channel> <title></title> <link></link>...
2
by: yannick.beot | last post by:
Hi, I have a problem with nested namespace in a schema. I defined a schema A. A is importing a schema B with the namespace nsB and a schema C with the namespace nsC. But both B and C are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.