|
I'm creating a typed DataSet for my XML file and I'm having trouble modifying the XSD file to conform to my data's format. Here's a sample of my data:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<dropdowns>
<Country lang="en">Albania</Country>
<Country lang="en">Algeria</Country>
...
I need for my Country data table to have two columns: "lang" and "name". How do I set up the XSD to treat the contents of the Country element as my name column? I've tried this, but it's not working:
<xs:element name="Dropdowns" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="Dropdowns" msprop:Generator_DataSetName="Dropdowns">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Country" form="unqualified" msprop:Generator_UserTableName="Country" msprop:Generator_RowDeletedName="CountryRowDeleted" msprop:Generator_RowChangedName="CountryRowChanged" msprop:Generator_RowClassName="CountryRow" msprop:Generator_RowChangingName="CountryRowChanging" msprop:Generator_RowEvArgName="CountryRowChangeEvent" msprop:Generator_RowEvHandlerName="CountryRowChangeEventHandler" msprop:Generator_TableClassName="CountryDataTable" msprop:Generator_TableVarName="tableCountry" msprop:Generator_RowDeletingName="CountryRowDeleting" msprop:Generator_TablePropName="Country">
<xs:complexType name="name" form="unqualified" msprop:Generator_UserColumnName="name" msprop:nullValue="_empty" msprop:Generator_ColumnPropNameInRow="name" msprop:Generator_ColumnPropNameInTable="nameColumn" msprop:Generator_ColumnVarNameInTable="columnname" type="xs:string" default="">
<xs:attribute name="lang" form="unqualified" msprop:Generator_UserColumnName="lang" msprop:nullValue="_throw" msprop:Generator_ColumnPropNameInRow="lang" msprop:Generator_ColumnPropNameInTable="langColumn" msprop:Generator_ColumnVarNameInTable="columnlang" type="xs:string" msdata:DefaultValue="en" use="required" />
</xs:complexType>
</xs:element>
How do I fix the part in bold?
Thanks!
Alvaro
Eat right. Exercise. Die anyway.
|
|
|
|
|
Hi All,
I am sure the solution to this is *Really* easy, but i've been staring at it for a while now and have got nowhere. I've written the test below in both C# and VB and both do the same thing.
I need to use an XmlReader object to read in an xml document. Note that it is essential that i use an XmlReader object as I need to perform schema validation. The code below does not incluse schema validation as as this stage i'm just trying to get an xml file into an XmlReader.
Looking in the msdn and a range of examples in google i should be able to get an XmlReader object containing my xml document by using XmlReader.Create(TextReader o). Everything is working right up until that step, but using the debug tools my XmlReader object appears to remain content-less. Here's the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace XmlTest
{
class Program
{
static void Main(string[] args)
{
String file = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\web.config";
XmlDocument doc = new XmlDocument();
doc.Load(new System.IO.StreamReader(file));
String docString = doc.OuterXml;
TextReader tr = new StringReader(docString);
XmlReader xr = XmlReader.Create(tr);
System.Console.ReadKey();
}
}
}
So we're loading in an xml file, putting it into an XmlDocument and getting the Xml as a string out of it. This is because ultimately when i slot this work back into what i'm doing i'll be obtaining the xml document via a string.
A TextReader object is then created from the string via a StringReader. If i debug the code i can see the document correctly loaded into the TextReader (tr) in it's entirity. It just doesn't seem to be converted into an XmlReader object via XmlReader.Create(tr).
Similarly, if i replace XmlReader.Create(tr) with XmlReader.Create(new System.IO.StreamReader(file)) I have the same problem, proving it's none of the logic inbetween that is messing things up.
What am i missing about XmlReader? Please help if you can, this is driving me absolutely nuts. When i look at it in debug the object has a depth of zero and looking in items i see "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user." I have no idea what this means and google doesn't help.
You should be able to copy and paste the code and replicate the issue easily.
Many thanks,
Rolf
|
|
|
|
|
I think the problem is that the reader isn't position on an XML node after being created, so you'll have to call any Read method before the properties (e.g. depth) return any useful information.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks Stefan, that was the problem. I'd been expecting the debug fields to populate as soon as the object had been created but as you say, running a ReadToEnd populated the fields.
Thanks,
Rolf
|
|
|
|
|
My web method returns some XML as a string. I have a fairly simple XSLT file (trying to create HTML SELECT OPTION tags from the XML content). I think both are OK but I cannot figure out how to pass the string of XML to the Transform method and get my desired output streamed out to the web page.
<code>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myProxyClass As New ServicesMDW.Service
Dim countiesXML As String
Dim xslt As New XslCompiledTransform()
Dim xpathdoc As XPathDocument
Dim xslFileName As String = Server.MapPath("UserControl_StateCounty.xsl")
Try
countiesXML = myProxyClass.GetCountiesForState("06", "P", "Guest")
xpathdoc = New XPathDocument(countiesXML)
xslt.Load(xslFileName)
xslt.Transform(xpathdoc, Nothing, Response.OutputStream)
Catch ex As Xsl.XsltException
Trace.Write("Transform Failed")
Catch ex As Exception
Trace.Write(ex.Message)
End Try
End Sub
</code>
Here is the XSLT file "UserControl_StateCounty.xsl":
<code>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div id="divCounty">
<label for="ddCounty">Select County</label>
<select id="ddCounty" >
<xsl:for-each select="Counties/County">
<option value="{County_Cd}"><xsl:value-of select='TypeCounty' /></option>
</xsl:for-each>
</select>
</div>
</xsl:template>
</xsl:stylesheet>
</code>
Here is a snippet of the XML returned from web method:
<code>
<Counties> <County> <County_Cd>001</County_Cd> <TypeCounty>Alameda</TypeCounty> <State_cd>06</State_cd> </County> <County> <County_Cd>005</County_Cd> <TypeCounty>AMADOR</TypeCounty> <State_cd>06</State_cd> </County></Counties>
</code>
John
|
|
|
|
|
Hi All
I am trying to generate code from one of my xml schema using Xsd.exe.
it throws the following error:
C:\>xsd C:\statement.xsd /c /l:cs
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Error: Error generating classes for schema 'C:\statement'.
- Group 'value' from targetNamespace='http://www.xyz.com/statement' has invalid definition: Circular group reference.
If you would like more help, please type "xsd /?".
Is there any solution for the problem with Circular group reference?
Gokulan
|
|
|
|
|
All,
what is the equvalent of in xsl i want to break a line what should i have to use....
Thanks
Vikas
|
|
|
|
|
Did you try google?
http://www.xml.com/pub/a/2001/12/05/whitespace.html[^]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
I use
<xsl:text> </xsl:text>
|
|
|
|
|
Hi ,
Im trying to transform an xml document with a style sheet that includes a vbscript file with vb script functions, using .net 1.1 and vb.net i get the following error when the code block attempts to transform the xml file.
The scripting language 'vbscript' is not supported.
Ive googled with very little help can someone please offer me a solution or advice !!
From my understanding this is .net security kicking in by not allowing server side scripts being included which may contain bad code nice but in this case its not helping me, in this case my intentions are good so i need this script to be trusted
Thank you in advance.
|
|
|
|
|
I am having a weird problem while validating an XML file against its schema. I am setting XmlReaderSettings to xml schema, add the ValidationEventHandler and then create the xml reader. But it throws an exception:
------------------
A first chance exception of type 'System.Xml.Schema.XmlSchemaValidationException' occurred in System.Xml.dll
validate function threw an exception of type 'System.Xml.Schema.XmlSchemaValidationException'
base {System.Xml.Schema.XmlSchemaException}: {"It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of {facets}, unless they are specified in different derivation steps. In which case the following must be true: the {value} of 'minLength' <= the {value} of 'length' <= the {value} of 'maxLength'."}
SourceObject: null
-----------------------
I have validated the same xml file against the same schema using Oxygen XML Editor and XML Spy and these tools consider it a valid document.
Now after that I opened the schema in VS 2005, it underlines the xsd:length attribute and tootip gives the same error. But the above mentioned third party tools consider it valid attribute.
Any thoughts will be highly appreciated
-----
|
|
|
|
|
|
hello gentlemen, im new at web services
all i've acomplished to do is to make the web reference...
the web reference i made of a web service that returns an xml
im sure of that because in the details page when i press invoke it returns a very large xml
my question is how to take that xml from the web service and somehow save it into the computer and transform it to be used by a dataset to feed a datagrid using windows forms in visual basic 2003 language visual basic
i've read a lot about web services but im alittle bit confused about all the xml things
the xml writters readers readxml etc (its simply confusing)
help is apreciated
thanks for your time
an expample of the xml that returns is here:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://services.naves.digmer.com/types/">
<env:Body>
<ns0:getNavesNavegandoResponseElement>
<ns0:result>
<naves>
<nave>
<nodo name="nombre">100PRE MI ROBERT</nodo>
<nodo name="senal_llamada">HC2733</nodo>
<nodo name="id_pais">EQA</nodo>
<nodo name="tb">22.61</nodo>
<nodo name="id_puerto_zarpe">2</nodo>
<nodo name="id_puerto_arribo">1170</nodo>
<nodo name="id_puerto_proximo"></nodo>
<nodo name="fecha_zarpe">10-04-2007 08:00:00</nodo>
<nodo name="fecha_estimada_arribo">09-05-2007 10:00:00</nodo>
<qth>
<nodo name="latitud">-0.8500000000</nodo>
<nodo name="longitud">-80.7000000000</nodo>
<nodo name="rumbo">0</nodo>
<nodo name="velocidad">0</nodo>
</qth>
<nodo name="estado">NAV</nodo>
</nave>
<nave>
<nodo name="nombre">2 MUJERES J.M.</nodo>
<nodo name="senal_llamada"></nodo>
<nodo name="id_pais">EQA</nodo>
<nodo name="tb">1.83</nodo>
<nodo name="id_puerto_zarpe">1</nodo>
<nodo name="id_puerto_arribo">1065</nodo>
<nodo name="id_puerto_proximo"></nodo>
<nodo name="fecha_zarpe">02-04-2007 09:00:00</nodo>
<nodo name="fecha_estimada_arribo">17-04-2007 06:00:00</nodo>
<qth>
<nodo name="latitud">-2.2297222222</nodo>
<nodo name="longitud">-79.8738888889</nodo>
<nodo name="rumbo">0</nodo>
<nodo name="velocidad">0</nodo>
</qth>
<nodo name="estado">NAV</nodo>
</nave>
:
:
'
</naves>
</ns0:result>
</ns0:getNavesNavegandoResponseElement>
</env:Body>
</env:Envelope>
"everything is possible"
|
|
|
|
|
i also get the same error about
System.Xml.dll
somehow the idea to try
dataset1.readxml(file.xml)<br />
datagrid1.datasource = dataset1
only gives me trouble
if i cant load an xml from a file, how is it possible to get it from a web service
and im starting to worry about that
|
|
|
|
|
Will you be so kind to tell me how do you search with xml using aspnet 2003.
Romeo
|
|
|
|
|
What do you mean by search with XML?
If you want to access a specific element or attribute of an XML file use XPath[^].
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
How to create a dynaic XSD
its very urgent
thank u
kishore kumar Manikonda
Software Developer
|
|
|
|
|
An XML Schema file is an XML file itself, so you can use the usual APIs like XmlDocument or XmlTextWriter .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
what is mean of "OUTER XML CONCEPTS"...
which purpose we r using..
how to use it...
|
|
|
|
|
I am trying to load a list of number in a combobox, it seems to be reading the xml file elements but it is reading my numbers as the index for the combobox
here is my xml file data that is is reading
<Days>21, "21"</Days>
<Days>20, "20"</Days>
<Days>19 19</Days>
<Days>18</Days>
<Days>17</Days>
<Days>16</Days>
<Days>15</Days>
<Days>14</Days>
<Days>13</Days>
<Days>12</Days>
<Days>11</Days>
<Days>10</Days>
all i get is a blank drop down list, if you want to see the code let me know but the code is working to read the other elements and filling text boxes
|
|
|
|
|
Hello,
I am Andrea from Italy.
ToDay I have download this script http://www.codeproject.com/asp/xml_messageboard.asp
and I have trouble.
I f I place html code in this page before the asp script, it return with strange simbol:
<%@ Language=VBScript %>
<%
' View Message
' prevent page caching
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
xslpath = Server.mappath("viewmessage.xsl") '"d:\InetPub\wwwroot\XMLmessageboard\messageboard.xsl"
xmlpath = Application("xmlpath")
Set id = Request.QueryString("id")
set xdoc = Application("xdoc")
set xsldoc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
'load up XSL doc and perform transformations
xsldoc.async = false
xsldoc.load(xslpath)
set xsltemp = Server.createObject("MSXML2.XSLTemplate")
xsltemp.stylesheet=xsldoc
set xslproc = xsltemp.createProcessor
xslproc.input=xdoc.nodeFromID(id)
xslproc.output=Response
' parameter for message group
xslproc.addParameter "msgid",CStr(id)
xslproc.transform()
%>
why ?
Thanks,
Andrea
|
|
|
|
|
The code is transforming a XML file with XSLT to recreate a HTML document. If you place HTML code before, during or after the code, you will have a malformed HTML document since you will have HTML code outside of scope of the <html> tag. If you want to add HTML code, you must modify the messageboard.xsl document.
|
|
|
|
|
... I can not modify the asp file? or there is not another way to trasform xml ?
|
|
|
|
|
Can you modify the xsl file?
|
|
|
|
|
Yes I can, but I would want to add other code asp ...
|
|
|
|