Hello (this is a frenchy message so : a very bad english...(
will be able to forgive me? )) :)
how then I to read the contents of a file xsd and to recover the value of
nodes and their children?
this program work but only for the principal node but not for children
if my shcema content
<xsd:element name="COMMENT">
<xsd:element name="CONSOMMATION">
<xsd:element name="OPTIONS">
<xsd:element name="PERSONNAL">
<xsd:element name="items">
my program write
COMMENT
CONSOMMATION
OPTIONS
PERSONNAL
items
but not
<xsd:element name="city" type="xsd:string" />
<xsd:element name="higtway" type="xsd:string" />
<xsd:element name="mix" type="xsd:string" />
in <xsd:element name="CONSOMMATION">
'first i chose a schema in a drop
'and i read the shcema in sql server 2005 like this
Dim cmdSql As String
cmdSql = "SELECT XML_SCHEMA_NAMESPACE(sch.name, xsd.name) FROM
sys.xml_schema_collections AS xsd "
cmdSql = cmdSql + "JOIN sys.schemas AS sch ON xsd.schema_id = sch.schema_id
WHERE xsd.name = '"
cmdSql = cmdSql + Session("dropSelect") + "'" ' drop select contents the
schema name in my sql server 2005
Dim xml As SqlXml
Dim xmlRdr As System.Xml.XmlReader
Dim conn As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("cs_vehicule").Connecti
onString)
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(cmdSql, conn)
Dim rdr As SqlDataReader = cmd.ExecuteReader
While rdr.Read
xml = rdr.GetSqlXml(0) ' GetSqlXml(0) = number of row where i can read xml
data
xmlRdr = xml.CreateReader
While xmlRdr.Read
Dim schema As XmlSchema
schema = XmlSchema.Read(xmlRdr, Nothing)
LblSchema.Text = schema.Id
Dim schemaObject As XmlSchemaObject
For Each schemaObject In schema.Items
If schemaObject.GetType() Is GetType(XmlSchemaElement) Then
'Dim ElementType As XmlSchemaElement = CType(schemaObject,
XmlSchemaElement)
'LblSchema.Text = LblSchema.Text + ElementType.Name.ToString + "<br/>"
Dim schemaSequence As XmlSchemaSequence
For Each schemaSequence In schema.Elements
Dim SequenceType As XmlSchemaSequence = CType(schemaObject,
XmlSchemaSequence)
LblSchema.Text = LblSchema.Text + SequenceType.Items.ToString(+"<br/>")
Next
End If
Next schemaObject
End While
xmlRdr.Close()
End While
rdr.Close()
conn.Close()
Thank youI am less concerned about your french influence than the VB code ;-)
Why don't you just use XQuery in the database to generate your output?
SELECT XML_SCHEMA_NAMESPACE(sch.name, xsd.name).query('for $n in
/xs:schema/xs:element/@.name return data($n)') FROM
sys.xml_schema_collections AS xsd
JOIN sys.schemas AS sch ON xsd.schema_id = sch.schema_id
WHERE xsd.name = @.dropSelect -- @.dropSelect is a parameter you pass from
your client program.
Best regards
Michael
"Helter Skelter" <nowhere-man@.apple.uk> wrote in message
news:45b88440$0$27410$ba4acef3@.news.orange.fr...
> Hello (this is a frenchy message so : a very bad english...(
> will be able to forgive me? )) :)
> how then I to read the contents of a file xsd and to recover the value of
> nodes and their children?
> this program work but only for the principal node but not for children
> if my shcema content
> <xsd:element name="COMMENT">
> <xsd:element name="CONSOMMATION">
> <xsd:element name="OPTIONS">
> <xsd:element name="PERSONNAL">
> <xsd:element name="items">
> my program write
> COMMENT
> CONSOMMATION
> OPTIONS
> PERSONNAL
> items
> but not
> <xsd:element name="city" type="xsd:string" />
> <xsd:element name="higtway" type="xsd:string" />
> <xsd:element name="mix" type="xsd:string" />
> in <xsd:element name="CONSOMMATION">
>
> 'first i chose a schema in a drop
> 'and i read the shcema in sql server 2005 like this
> Dim cmdSql As String
> cmdSql = "SELECT XML_SCHEMA_NAMESPACE(sch.name, xsd.name) FROM
> sys.xml_schema_collections AS xsd "
> cmdSql = cmdSql + "JOIN sys.schemas AS sch ON xsd.schema_id =
> sch.schema_id
> WHERE xsd.name = '"
> cmdSql = cmdSql + Session("dropSelect") + "'" ' drop select contents the
> schema name in my sql server 2005
> Dim xml As SqlXml
> Dim xmlRdr As System.Xml.XmlReader
> Dim conn As SqlConnection = New
> SqlConnection(ConfigurationManager.ConnectionStrings("cs_vehicule").Connec
tionString)
> conn.Open()
> Dim cmd As SqlCommand = New SqlCommand(cmdSql, conn)
> Dim rdr As SqlDataReader = cmd.ExecuteReader
> While rdr.Read
> xml = rdr.GetSqlXml(0) ' GetSqlXml(0) = number of row where i can read
> xml data
> xmlRdr = xml.CreateReader
> While xmlRdr.Read
> Dim schema As XmlSchema
> schema = XmlSchema.Read(xmlRdr, Nothing)
> LblSchema.Text = schema.Id
> Dim schemaObject As XmlSchemaObject
> For Each schemaObject In schema.Items
> If schemaObject.GetType() Is GetType(XmlSchemaElement) Then
> 'Dim ElementType As XmlSchemaElement = CType(schemaObject,
> XmlSchemaElement)
> 'LblSchema.Text = LblSchema.Text + ElementType.Name.ToString + "<br/>"
> Dim schemaSequence As XmlSchemaSequence
> For Each schemaSequence In schema.Elements
> Dim SequenceType As XmlSchemaSequence = CType(schemaObject,
> XmlSchemaSequence)
> LblSchema.Text = LblSchema.Text +
> SequenceType.Items.ToString(+"<br/>")
> Next
> End If
> Next schemaObject
> End While
> xmlRdr.Close()
> End While
> rdr.Close()
> conn.Close()
>
> Thank you
>|||Dear Michael
thank you for your humour and the interest which you carry to my work.
I build a super market which will be able to sell televisions, cars,
computers, vegetables and shirts (laughter).
My base "sql server" contains a single table for all these articles.
Only one fields will be different: that of the characteristics (in xml).
So I have different diagrams xml according to item (to be able to compare
them). I currently have 27 possible diagrams !
The characteristics of a television are different from a car.
When I read a recording, fields indicates to me which is the diagram that I
must associate for good read the fields of the characteristics.
The diagram xsd will be useful to me for the validation of a new seizure or
a modification.
It must also serve to me to create on my Web page the "labels" and "textbox"
during creation as the recording to fill my fields xml of the
characteristics.
When I create a new article, I must say:
1) which is its diagram (dropdownlist)
2) to read which are the fields contained in the diagram
3) to create its fields on my page
example:
video chart
--processor speed
--RAM
mother board
--chipset
--a number of slot
When I create a new article, it is by reading the diagram that I will find
which are the fields to be created.
For this reason I read the diagram in "sql server 2005"
Let us be us always friendly (laughter ) ?
A splendid time is guaranteed for all !
"Michael Rys [MSFT]" <mrys@.online.microsoft.com> a crit dans le message de
news: %23ApgopPQHHA.4992@.TK2MSFTNGP04.phx.gbl...
>I am less concerned about your french influence than the VB code ;-)
> Why don't you just use XQuery in the database to generate your output?
> SELECT XML_SCHEMA_NAMESPACE(sch.name, xsd.name).query('for $n in
> /xs:schema/xs:element/@.name return data($n)') FROM
> sys.xml_schema_collections AS xsd
> JOIN sys.schemas AS sch ON xsd.schema_id = sch.schema_id
> WHERE xsd.name = @.dropSelect -- @.dropSelect is a parameter you pass from
> your client program.
> Best regards
> Michael
> "Helter Skelter" <nowhere-man@.apple.uk> wrote in message
> news:45b88440$0$27410$ba4acef3@.news.orange.fr...
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment