UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> XsdCTSequence    
CODE

'---------------------------------------------------------------------------------------------------------------------------------------
' XsdCTSequence
' http://www.utteraccess.com/wiki/index.php/FunctionNameHere
' Code courtesy of UtterAccess Wiki
' Original submission by Diego F.Pereira-Perdomo
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2012-07-10                    Creates Complex Type Sequence XSD files.
'                                       strElements: A string that contains the XSD Child elements.
'                                       xsdPath:     The path in which the XSD File is going to be saved.
'                                       xsdName:     The name of the XSD File
'---------------------------------------------------------------------------------------------------------------------------------------
Public Function XsdCTSequence(strElements As String, _
                                 xsdPath As String, _
                                 xsdName As String)
On Error GoTo ErrorHandler

Dim pXsd    As String
Dim fXsd    As Long

fXsd = FreeFile

' Writes the Parent elements.

pXsd = "<?xml version='1.0' encoding='UTF-8'?>" & _
       vbCrLf
   pXsd = pXsd & "<xsd:schema " & _
                 "xmlns:xsd='http://www.w3.org/2001/XMLSchema' " & _
                 "xmlns:od='urn:schemas-microsoft-com:officedata'>" & _
          vbCrLf
       pXsd = pXsd & "<xsd:element name='dataroot'>" & _
              vbCrLf
           pXsd = pXsd & "<xsd:complexType>" & _
                  vbCrLf
               pXsd = pXsd & "<xsd:sequence>" & _
                      vbCrLf
                   pXsd = pXsd & "<xsd:element ref='" & xsdName & "' " & _
                                 "minOccurs='0' " & _
                                 "maxOccurs='unbounded'/>" & _
                          vbCrLf
               pXsd = pXsd & "</xsd:sequence>" & _
                      vbCrLf
           pXsd = pXsd & "</xsd:complexType>" & _
                  vbCrLf
       pXsd = pXsd & "</xsd:element>" & _
              vbCrLf
       pXsd = pXsd & "<xsd:element name='" & xsdName & "'>" & _
              vbCrLf
           pXsd = pXsd & "<xsd:complexType>" & _
                  vbCrLf
               pXsd = pXsd & "<xsd:sequence>" & _
                      vbCrLf
                   
                   ' Writes the Child elements from the variable strElements.
                   
                   pXsd = pXsd & strElements
   
               ' Writes the End tags of the Parent elements.
   
               pXsd = pXsd & "</xsd:sequence>" & _
                      vbCrLf
           pXsd = pXsd & "</xsd:complexType>" & _
                  vbCrLf
       pXsd = pXsd & "</xsd:element>" & _
              vbCrLf
   pXsd = pXsd & "</xsd:schema>"

' Creates the XSD file.

Open xsdPath For Output As #fXsd ' Opens the XSD file.

   Print #fXsd, pXsd


ExitFunction:

Close #fXsd ' Closes the XSD File

Exit Function

ErrorHandler:
Select Case Err.Number
   Case 0
   Case Else
       MsgBox Err.Number & ": " & Err.Description
       Resume ExitFunction
End Select
 
End Function

Creative Commons License
XsdCTSequence by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 1,591 times.  This page was last modified 06:54, 10 July 2012 by dipetete.   Disclaimers