"""
 Module for some commonly used functions.
"""

import clr
clr.AddReference('System.Xml')

import System
import System.IO
import System.Xml
import System.Xml.XPath

from System.IO import Path

import resolver

def LoadXmlWithoutResolver(ParamPath):
  VarResult = None

  VarReader = System.Xml.XmlTextReader(ParamPath)
  VarReader.XmlResolver = resolver.EmptyUrlResolver(ParamPath, Path.GetDirectoryName(__file__))
  VarDocument = System.Xml.XPath.XPathDocument(VarReader, System.Xml.XmlSpace.None)

  VarResult = VarDocument.CreateNavigator()

  return VarResult

def MakeXmlWriter(ParamPath):
  VarResult = None

  VarResult = System.Xml.XmlTextWriter(System.IO.StreamWriter(ParamPath))
  VarResult.Formatting = System.Xml.Formatting.Indented
  VarResult.Indentation = 1
  VarResult.IndentChar = ' '

  return VarResult
