Discussion:
Parsing XML Schemas in .NET
(trop ancien pour répondre)
dedZep
2007-02-07 17:53:00 UTC
Permalink
sur cette page
http://www.xmlforasp.net/CodeBank/System_Xml_Schema/ParseSchema/ParseXMLSchema.aspx

l'auteur a reussi a faire ce que je cherche depuis plusieurs mois

dans le tutorial joint http://www.xmlforasp.net/codeSection.aspx?csID=78
le code source ne marche helas qu'avec asp.net 1

Sauriez vous le faire en asp.net 2.0

Cette demande est essentielle pour continuer mon travail



Merci a vous :)
dedZep
2007-02-08 12:24:01 UTC
Permalink
voici le type d'erreur que j'ai en suivant l'exemple du blog
c'est toujours dans les test if
par exemple
'-----error "XmlSchemaComplexType" is a type and cannot be used as
an expression.



'--------------------
'
Dim schemaSet As XmlSchemaSet = New XmlSchemaSet
schemaSet.Add(Nothing, "schema.xsd")
schemaSet.Compile


'--------------------
'
For Each schema As XmlSchema In ss.Schemas

'------------------------------------------------
' stepping through global complex typesFor Each type As XmlSchemaType In
schema.SchemaTypes.Values
'------------------------------------------------
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as
an expression.
End If
Next

'------------------------------------------------
' stepping through global elements
'------------------------------------------------
For Each el As XmlSchemaElement In schema.Elements.Values

Next
'------------------------------------------------
' stepping through named groups
'------------------------------------------------
For Each xsa As XmlSchemaAnnotated In schema.Items
If (xsa = XmlSchemaGroup) Then
'-----error "XmlSchemaGroup" is a type and cannot be used as an
expression.

End If
Next


'------------------------------------------
'
Private Sub walkTheParticle(ByVal particle As XmlSchemaParticle)
If (particle = XmlSchemaElement) Then
'-----error "XmlSchemaElement" is a type and cannot be used as an
expression.

Dim elem As XmlSchemaElement = CType(particle,XmlSchemaElement)
' todo: insert your processing code here
If elem.RefName.IsEmpty Then
Dim type As XmlSchemaType =
CType(elem.ElementSchemaType,XmlSchemaType)
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as an
expression.

Dim ct As XmlSchemaComplexType =
CType(type,XmlSchemaComplexType)
If ct.QualifiedName.IsEmpty Then
walkTheParticle(ct.ContentTypeParticle)
End If
End If
End If
ElseIf (particle = XmlSchemaGroupBase) Then
'-----error "XmlSchemaGroupBase" is a type and cannot be used as an
expression.

Dim baseParticle As XmlSchemaGroupBase =
CType(particle,XmlSchemaGroupBase)
For Each subParticle As XmlSchemaParticle In baseParticle.Items
walkTheParticle(subParticle)
Next
End If
End Sub

'--------------------------
Private Sub start(ByVal ss As XmlSchemaSet)
For Each schema As XmlSchema In ss.Schemas
For Each type As XmlSchemaType In schema.SchemaTypes.Values
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as an
expression.

Dim ct As XmlSchemaComplexType =
CType(type,XmlSchemaComplexType)
walkTheParticle(ct.ContentTypeParticle)
End If
Next
For Each el As XmlSchemaElement In schema.Elements.Values
walkTheParticle(el)
Next
For Each xsa As XmlSchemaAnnotated In schema.Items
If (xsa = XmlSchemaGroup) Then
'-----error "XmlSchemaGroup" is a type and cannot be used as an
expression.
Dim xsg As XmlSchemaGroup = CType(xsa,XmlSchemaGroup)
walkTheParticle(xsg.Particle)
End If
Next
Next
End Sub
Post by dedZep
sur cette page
http://www.xmlforasp.net/CodeBank/System_Xml_Schema/ParseSchema/ParseXMLSchema.aspx
l'auteur a reussi a faire ce que je cherche depuis plusieurs mois
dans le tutorial joint http://www.xmlforasp.net/codeSection.aspx?csID=78
le code source ne marche helas qu'avec asp.net 1
Sauriez vous le faire en asp.net 2.0
Cette demande est essentielle pour continuer mon travail
Merci a vous :)
Paul Bacelar
2007-02-24 03:07:29 UTC
Permalink
Remplacez les "=" pas "is" ;-)
--
Paul Bacelar
MVP VC++
Post by dedZep
voici le type d'erreur que j'ai en suivant l'exemple du blog
c'est toujours dans les test if
par exemple
'-----error "XmlSchemaComplexType" is a type and cannot be used as
an expression.
'--------------------
'
Dim schemaSet As XmlSchemaSet = New XmlSchemaSet
schemaSet.Add(Nothing, "schema.xsd")
schemaSet.Compile
'--------------------
'
For Each schema As XmlSchema In ss.Schemas
'------------------------------------------------
' stepping through global complex typesFor Each type As XmlSchemaType In
schema.SchemaTypes.Values
'------------------------------------------------
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as
an expression.
End If
Next
'------------------------------------------------
' stepping through global elements
'------------------------------------------------
For Each el As XmlSchemaElement In schema.Elements.Values
Next
'------------------------------------------------
' stepping through named groups
'------------------------------------------------
For Each xsa As XmlSchemaAnnotated In schema.Items
If (xsa = XmlSchemaGroup) Then
'-----error "XmlSchemaGroup" is a type and cannot be used as an
expression.
End If
Next
'------------------------------------------
'
Private Sub walkTheParticle(ByVal particle As XmlSchemaParticle)
If (particle = XmlSchemaElement) Then
'-----error "XmlSchemaElement" is a type and cannot be used as an
expression.
Dim elem As XmlSchemaElement = CType(particle,XmlSchemaElement)
' todo: insert your processing code here
If elem.RefName.IsEmpty Then
Dim type As XmlSchemaType =
CType(elem.ElementSchemaType,XmlSchemaType)
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as an
expression.
Dim ct As XmlSchemaComplexType =
CType(type,XmlSchemaComplexType)
If ct.QualifiedName.IsEmpty Then
walkTheParticle(ct.ContentTypeParticle)
End If
End If
End If
ElseIf (particle = XmlSchemaGroupBase) Then
'-----error "XmlSchemaGroupBase" is a type and cannot be used as an
expression.
Dim baseParticle As XmlSchemaGroupBase =
CType(particle,XmlSchemaGroupBase)
For Each subParticle As XmlSchemaParticle In baseParticle.Items
walkTheParticle(subParticle)
Next
End If
End Sub
'--------------------------
Private Sub start(ByVal ss As XmlSchemaSet)
For Each schema As XmlSchema In ss.Schemas
For Each type As XmlSchemaType In schema.SchemaTypes.Values
If (type = XmlSchemaComplexType) Then
'-----error "XmlSchemaComplexType" is a type and cannot be used as an
expression.
Dim ct As XmlSchemaComplexType =
CType(type,XmlSchemaComplexType)
walkTheParticle(ct.ContentTypeParticle)
End If
Next
For Each el As XmlSchemaElement In schema.Elements.Values
walkTheParticle(el)
Next
For Each xsa As XmlSchemaAnnotated In schema.Items
If (xsa = XmlSchemaGroup) Then
'-----error "XmlSchemaGroup" is a type and cannot be used as an
expression.
Dim xsg As XmlSchemaGroup = CType(xsa,XmlSchemaGroup)
walkTheParticle(xsg.Particle)
End If
Next
Next
End Sub
Post by dedZep
sur cette page
http://www.xmlforasp.net/CodeBank/System_Xml_Schema/ParseSchema/ParseXMLSchema.aspx
l'auteur a reussi a faire ce que je cherche depuis plusieurs mois
dans le tutorial joint
http://www.xmlforasp.net/codeSection.aspx?csID=78
le code source ne marche helas qu'avec asp.net 1
Sauriez vous le faire en asp.net 2.0
Cette demande est essentielle pour continuer mon travail
Merci a vous :)
dedZep
2007-02-24 14:01:08 UTC
Permalink
merci Paul

j'ai trouvé une synthaxe encore plus precise

If TypeOf elem.SchemaType Is XmlSchemaComplexType Then

avec effectivement le remplacement du "=" par le "is"

merci
Post by Paul Bacelar
Remplacez les "=" pas "is" ;-)
--
Paul Bacelar
MVP VC++
Loading...