home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _AA96D54DB8BA4B8589E40E4567E2CE9C < prev    next >
Encoding:
Text File  |  2003-05-21  |  8.7 KB  |  299 lines

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // [=$module].cpp
  4. //
  5. // This file was generated by XMLSPY 5 Enterprise Edition.
  6. //
  7. // YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
  8. // OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
  9. //
  10. // Refer to the XMLSPY Documentation for further details.
  11. // http://www.altova.com/xmlspy
  12. //
  13. ////////////////////////////////////////////////////////////////////////
  14.  
  15.  
  16. #include "StdAfx.h"
  17. #include "[=$module].h"
  18.  
  19.  
  20. [if $domtype = 1]
  21. void C[=$module]Doc::DeclareNamespaces(CNode& rNode)
  22. {
  23. [foreach $namespace in $namespaces
  24.     if $namespace.URI <> ""
  25. ]    DeclareNamespace(rNode, _T("[=$namespace.Prefix]"), _T("[=$namespace.URI]"));
  26. [    endif
  27. next
  28. ]}
  29. [else]
  30. void C[=$module]Doc::DeclareNamespaces(xercesc::DOMElement* pElement)
  31. {
  32. [foreach $namespace in $namespaces
  33.     if $namespace.URI <> ""
  34. ]    DeclareNamespace(pElement, _T("[=$namespace.Prefix]"), _T("[=$namespace.URI]"));
  35. [    endif
  36. next
  37. ]}
  38. [endif]
  39.  
  40.  
  41. [
  42. foreach $class in $classes : if not $class.IsInternal
  43.     if $class.NamespacePrefix <> ""
  44. ]namespace [=$class.NamespacePrefix][if $class.NamespaceURI <> ""] // URI: [=$class.NamespaceURI][endif]
  45. {
  46. [    endif
  47. ]////////////////////////////////////////////////////////////////////////
  48. //
  49. // class [=$class.Name]
  50. //
  51. ////////////////////////////////////////////////////////////////////////
  52.  
  53.  
  54. [
  55.     if $class.IsComplexType
  56.         if not $class.IsComplexFromSimpleType
  57. ]CNode::EGroupType [=$class.Name]::GetGroupType()
  58. {
  59. [            if $class.IsChoice
  60. ]    return eChoice;
  61. [            else : if $class.IsAll
  62. ]    return eAll;
  63. [            else
  64. ]    return eSequence;
  65. [            endif : endif
  66. ]}
  67.  
  68.  
  69. [if $domtype = 2]
  70. void [=$class.Name]::AdjustPrefix()
  71. {
  72.     int i, nCount;
  73. [        foreach $member in $class.Members
  74.             if $member.IsQualified
  75.                 $IsQualified = "true"
  76.             else
  77.                 $IsQualified = "false"
  78.             endif
  79.             if $member.HasTypeObject
  80.                 if $member.TypeObject.NamespacePrefix <> $class.NamespacePrefix
  81.                     $QualifiedType = $member.TypeObject.NamespacePrefix & "::" & $member.Type
  82.                 else
  83.                     $QualifiedType = $member.Type
  84.                 endif
  85.             else
  86.                 $QualifiedType = $member.Type
  87.             endif
  88. ]
  89.     nCount = ChildCountInternal([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$member.SchemaName]"));
  90.     for (i = 0; i < nCount; i++)
  91.     {
  92.         [if $domtype = 1]MSXML2::IXMLDOMNodePtr[else]xercesc::DOMNode*[endif] pDOMNode = InternalGetAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$member.SchemaName]"), i);
  93.         InternalAdjustPrefix(pDOMNode, [=$IsQualified]);
  94. [            if $member.HasTypeObject and $member.TypeObject.IsComplexType
  95. ]        [=$QualifiedType](pDOMNode).AdjustPrefix();
  96. [            endif
  97. ]    }
  98. [
  99.         next
  100. ]}
  101. [endif]
  102.  
  103. [        endif
  104.         foreach $member in $class.Members
  105.             if $domtype = 1
  106.                 $QualifiedName = $member.XmlName
  107.             else
  108.                 $QualifiedName = $member.SchemaName
  109.             endif
  110.             if $member.HasTypeObject
  111.                 if $member.TypeObject.NamespacePrefix <> $class.NamespacePrefix
  112.                     $QualifiedType = $member.TypeObject.NamespacePrefix & "::" & $member.Type
  113.                 else
  114.                     $QualifiedType = $member.Type
  115.                 endif
  116.             else
  117.                 $QualifiedType = $member.Type
  118.             endif
  119. ]int [=$class.Name]::Get[=$member.Name]MinCount()
  120. {
  121.     return [=$member.MinOcc];
  122. }
  123.  
  124.  
  125. int [=$class.Name]::Get[=$member.Name]MaxCount()
  126. {
  127.     return [if $member.MaxOcc = -1]INT_MAX[else][=$member.MaxOcc][endif];
  128. }
  129.  
  130.  
  131. int [=$class.Name]::Get[=$member.Name]Count()
  132. {
  133.     return ChildCountInternal([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"));
  134. }
  135.  
  136.  
  137. bool [=$class.Name]::Has[=$member.Name]()
  138. {
  139.     return InternalHasChild([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"));
  140. }
  141.  
  142.  
  143. [            if $member.IsSimpleType
  144. ]void [=$class.Name]::Add[=$member.Name]([=$QualifiedType] [=$member.Name])
  145. {
  146.     InternalAppend([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), [=$member.Name]);
  147. }
  148.  
  149.  
  150. void [=$class.Name]::Insert[=$member.Name]At([=$QualifiedType] [=$member.Name], int nIndex)
  151. {
  152.     InternalInsertAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex, [=$member.Name]);
  153. }
  154.  
  155.  
  156. void [=$class.Name]::Replace[=$member.Name]At([=$QualifiedType] [=$member.Name], int nIndex)
  157. {
  158.     InternalReplaceAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex, [=$member.Name]);
  159. }
  160. [            else
  161. ]void [=$class.Name]::Add[=$member.Name]([=$QualifiedType]& [=$member.Name])
  162. {
  163.     InternalAppendNode(_T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), [=$member.Name]);
  164. }
  165.  
  166.  
  167. void [=$class.Name]::Insert[=$member.Name]At([=$QualifiedType]& [=$member.Name], int nIndex)
  168. {
  169.     InternalInsertNodeAt(_T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex, [=$member.Name]);
  170. }
  171.  
  172.  
  173. void [=$class.Name]::Replace[=$member.Name]At([=$QualifiedType]& [=$member.Name], int nIndex)
  174. {
  175.     InternalReplaceNodeAt(_T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex, [=$member.Name]);
  176. }
  177. [            endif
  178. ]
  179.  
  180. [if $domtype = 1]
  181. [=$QualifiedType] [=$class.Name]::Get[=$member.Name]At(int nIndex)
  182. {
  183. [            if $member.IsSimpleType
  184. ]    return (LPCTSTR)InternalGetAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex)->text;
  185. [            else
  186. ]    return [=$QualifiedType](*this, InternalGetAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex));
  187. [            endif
  188. ]}
  189. [else]
  190. [=$QualifiedType] [=$class.Name]::Get[=$member.Name]At(int nIndex)
  191. {
  192. [            if $member.IsSimpleType
  193. ]    return InternalGetNodeValue([=$member.NodeType], InternalGetAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex)).c_str();
  194. [            else
  195. ]    return [=$QualifiedType](InternalGetAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex));
  196. [            endif
  197. ]}
  198. [endif]
  199.  
  200.  
  201. [=$QualifiedType] [=$class.Name]::Get[=$member.Name]()
  202. {
  203.     return Get[=$member.Name]At(0);
  204. }
  205.  
  206.  
  207. void [=$class.Name]::Remove[=$member.Name]At(int nIndex)
  208. {
  209.     InternalRemoveAt([=$member.NodeType], _T("[=$member.NamespaceURI]"), _T("[=$QualifiedName]"), nIndex);
  210. }
  211.  
  212.  
  213. void [=$class.Name]::Remove[=$member.Name]()
  214. {
  215. [            if $member.MaxOcc > 1
  216. ]    Remove[=$member.Name]At(0);
  217. [            else
  218. ]    while (Has[=$member.Name]())
  219.         Remove[=$member.Name]At(0);
  220. [endif
  221. ]}
  222.  
  223. [        next
  224.     else : if $class.IsSimpleType
  225.         if $class.Base = $class.BuiltInBase
  226.             $IsDirectChild = true
  227.         else
  228.             $IsDirectChild = false
  229.         endif
  230. ][=$class.Name]::[=$class.Name]([=$class.BuiltInBase]::basetype Value) : [=$class.Base](Value)
  231. {
  232.     Validate();
  233. }
  234.  
  235.  
  236. [=$class.Name]::[=$class.Name](tstring Value) : [=$class.Base](Value.c_str())
  237. {
  238.     Validate();
  239. }
  240.  
  241.  
  242. void [=$class.Name]::Validate()
  243. {
  244. [
  245.         $BuiltInType = $class.BuiltInSchemaBase
  246.         if $BuiltInType = "base64Binary" or $BuiltInType = "hexBinary"
  247.             $InstanceLength = "m_nSize"
  248.         else
  249.             $InstanceLength = "m_Value.size()"
  250.         endif
  251.         if $BuiltInType = "time" or $BuiltInType = "date" or $BuiltInType = "dateTime"
  252.             $InstanceValue = "*this"
  253.         else
  254.             $InstanceValue = "m_Value"
  255.         endif
  256.         if $BuiltInType = "duration" or $BuiltInType = "gYear" or $BuiltInType = "gYearMonth" or $BuiltInType = "gMonth" or $BuiltInType = "gMonthDay" or $BuiltInType = "gDay"
  257.             $AllowComparison = false
  258.         else
  259.             $AllowComparison = true
  260.         endif
  261.  
  262.         foreach $facet in $class.Facets
  263.             if $facet.IsMinLength
  264. ]    if ([=$InstanceLength] < GetMinLength())
  265.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  266. [            else:if $facet.IsMaxLength
  267. ]    if ([=$InstanceLength] > GetMaxLength())
  268.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  269. [            else:if $facet.IsLength
  270. ]    if ([=$InstanceLength] != GetLength())
  271.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  272. [            else:if $facet.IsMinInclusive and $AllowComparison
  273. ]    if ([=$InstanceValue] < GetMinInclusive())
  274.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  275. [            else:if $facet.IsMinExclusive and $AllowComparison
  276. ]    if ([=$InstanceValue] <= GetMinExclusive())
  277.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  278. [            else:if $facet.IsMaxExclusive and $AllowComparison
  279. ]    if ([=$InstanceValue] >= GetMaxExclusive())
  280.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  281. [            else:if $facet.IsMaxInclusive and $AllowComparison
  282. ]    if ([=$InstanceValue] > GetMaxInclusive())
  283.         throw CXmlException(CXmlException::eError1, _T("Validation error"));
  284. [            else:if $facet.IsTotalDigits
  285.             else:if $facet.IsFractionDigits
  286.             else:if $facet.IsWhiteSpace
  287.             else:if $facet.IsPattern
  288.             else:if $facet.IsEnumeration
  289.             endif:endif:endif:endif:endif:endif:endif:endif:endif:endif:endif:endif
  290.     next
  291. ]}
  292.  
  293.  
  294. [    endif : endif
  295.     if $class.NamespacePrefix <> ""
  296. ]} // end of namespace [=$class.NamespacePrefix]
  297. [    endif
  298. endif : next
  299. ]