Create an XML RelaxNGs parse context for that file/resource
       expected to contain an XML RelaxNGs file.
329295
def relaxNGNewParserCtxt(URL):
    
    ret = libxml2mod.xmlRelaxNGNewParserCtxt(URL)
    if ret is None:raise parserError('xmlRelaxNGNewParserCtxt() failed')
    return relaxNgParserCtxt(_obj=ret)
597237
private Document parseExtensionFile(String serviceName) {

		String extensionFileName = serviceName + "-Extensions.xml";

    	if (isIddAsResource()) {
    		InputStream is = resourceLoader.getResourceAsStream(extensionFileName);
    		if (is != null) {
    			return XmlUtil.parse(is, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    	else {
    		File extensionsFile = new File( new File(getBaseDir(), RESOURCES_DIR), extensionFileName);
    		if (extensionsFile.exists()) {
        		return XmlUtil.parse(extensionsFile, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    }
641215
def context(self):
        
        ret = libxml2mod.xmlXPathParserGetContext(self._o)
        if ret is None:raise xpathError('xmlXPathParserGetContext() failed')
        __tmp = xpathContext(_obj=ret)
        return __tmp
901719
@Override
	public InputStream createResourceAsStream(GeneratorContext context) {

		String path = context.getPath();
		return rd.getResourceAsStream(path);
	}
607469
def parse(cls, resource, parent=None):
        
        xml = xmlparser(resource)
        o = cls(urn=xml.get("urn"), parent=parent)

        for child in xml.xpath("ti:groupname", namespaces=XPATH_NAMESPACES):
            lg = child.get("{http://www.w3.org/XML/1998/namespace}lang")
            if lg is not None:
                o.set_cts_property("groupname", child.text, lg)

        # Parse Works
        _xpathDict(xml=xml, xpath='ti:work', cls=cls.CLASS_WORK, parent=o)

        _parse_structured_metadata(o, xml)
        return o
1184994
def create_layer_from_metadata_xml(resourcetype, xml, monitor=False, service=None, catalog=None):
    
    from models import gen_anytext, Layer

    if resourcetype == 'http://www.opengis.net/cat/csw/2.0.2':  # Dublin core
        md = CswRecord(etree.fromstring(xml))

    layer = Layer(
        is_monitored=monitor,
        name=md.title,
        title=md.title,
        abstract=md.abstract,
        xml=xml,
        service=service,
        catalog=catalog,
        anytext=gen_anytext(md.title, md.abstract, md.subjects)
    )

    if hasattr(md, 'alternative'):
        layer.name = md.alternative

    if md.bbox is not None:
        layer.bbox_x0 = format_float(md.bbox.minx)
        layer.bbox_y0 = format_float(md.bbox.miny)
        layer.bbox_x1 = format_float(md.bbox.maxx)
        layer.bbox_y1 = format_float(md.bbox.maxy)

        layer.wkt_geometry = bbox2wktpolygon([md.bbox.minx, md.bbox.miny, md.bbox.maxx, md.bbox.maxy])

    return layer, md.subjects
257178
private static SAXParser createSAXParser()
      throws ParserConfigurationException, SAXException {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setXIncludeAware(false);
    factory.setFeature(
        "http://xml.org/sax/features/external-general-entities", false);
    factory.setFeature(
        "http://xml.org/sax/features/external-parameter-entities", false);
    factory.setFeature(
        "http://apache.org/xml/features/nonvalidating/load-external-dtd",
        false);
    factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

    SAXParser parser = factory.newSAXParser();
    XMLReader xmlReader = parser.getXMLReader();
    xmlReader.setEntityResolver(NOOP_RESOLVER);
    return parser;
  }
473689
function create(context) {
    const ignoredFiles = context.options[0] || [];

    return {
        Program(node) {
            const filename = basename(context.getFilename());

            if (includes(ignoredFiles, filename)) return;

            if (!node.body.every(isDefineExpr)) {
                context.report(node, message);
            }
        }
    };
}
1162842
def fill_schema_from_xsd_file(filename, schema):
    
    ifmap_statements = _parse_xsd_file(filename)
    properties_all = []

    for v in ifmap_statements.values():
        if (isinstance(v[0], IDLParser.Link)):
            src_name = v[1]
            target_name = v[2]
            src = schema._get_or_add_resource(src_name)
            target = schema._get_or_add_resource(target_name)
            if "has" in v[3]:
                src.children.append(target_name)
                target.parent = src_name
            if "ref" in v[3]:
                src.refs.append(target_name)
                target.back_refs.append(src_name)
        elif isinstance(v[0], IDLParser.Property):
            target_name = v[1][0]
            prop = ResourceProperty(v[0].name, is_list=v[0].is_list, is_map=v[0].is_map)
            if target_name != 'all':
                target = schema._get_or_add_resource(target_name)
                target.properties.append(prop)
            else:
                properties_all.append(prop)

    for r in schema.all_resources():
        schema.resource(r).properties += properties_all
1278910
def _loadContext(context, xmlElement, attributeToFormatMap):
    
    attribute = _safeGetRequiredAttribute(xmlElement, 'attribute', '<not set>').lower()
    if attribute != '<not set>':  # there are no attributes for internal contexts, used by rules. See perl.xml
        try:
            format = attributeToFormatMap[attribute]
        except KeyError:
            _logger.warning('Unknown context attribute %s', attribute)
            format = TextFormat()
    else:
        format = None

    textType = format.textType if format is not None else ' '
    if format is not None:
        format = _convertFormat(format)

    lineEndContextText = xmlElement.attrib.get('lineEndContext', '#stay')
    lineEndContext = _makeContextSwitcher(lineEndContextText,  context.parser)
    lineBeginContextText = xmlElement.attrib.get('lineBeginContext', '#stay')
    lineBeginContext = _makeContextSwitcher(lineBeginContextText, context.parser)
    lineEmptyContextText = xmlElement.attrib.get('lineEmptyContext', '#stay')
    lineEmptyContext = _makeContextSwitcher(lineEmptyContextText, context.parser)

    if _parseBoolAttribute(xmlElement.attrib.get('fallthrough', 'false')):
        fallthroughContextText = _safeGetRequiredAttribute(xmlElement, 'fallthroughContext', '#stay')
        fallthroughContext = _makeContextSwitcher(fallthroughContextText, context.parser)
    else:
        fallthroughContext = None

    dynamic = _parseBoolAttribute(xmlElement.attrib.get('dynamic', 'false'))

    context.setValues(attribute, format, lineEndContext, lineBeginContext, lineEmptyContext, fallthroughContext, dynamic, textType)

    # load rules
    rules = _loadChildRules(context, xmlElement, attributeToFormatMap)
    context.setRules(rules)
603178
def relaxNGNewValidCtxt(self):
        
        ret = libxml2mod.xmlRelaxNGNewValidCtxt(self._o)
        if ret is None:raise treeError('xmlRelaxNGNewValidCtxt() failed')
        __tmp = relaxNgValidCtxt(_obj=ret)
        __tmp.schema = self
        return __tmp
417966
def _prepare_xml(options=None, state=None):
    '''
    
    '''

    if state:
        _state = '0'
    else:
        _state = '2'

    xml = "<?xml version='1.0'?>\n<checkresults>\n"

    # No service defined then we set the status of the hostname
    if 'service' in options and options['service'] != '':
        xml += "<checkresult type='service' checktype='" + six.text_type(options['checktype'])+"'>"
        xml += "<hostname>"+cgi.escape(options['hostname'], True)+"</hostname>"
        xml += "<servicename>"+cgi.escape(options['service'], True)+"</servicename>"
    else:
        xml += "<checkresult type='host' checktype='" + six.text_type(options['checktype'])+"'>"
        xml += "<hostname>"+cgi.escape(options['hostname'], True)+"</hostname>"

    xml += "<state>"+_state+"</state>"

    if 'output' in options:
        xml += "<output>"+cgi.escape(options['output'], True)+"</output>"

    xml += "</checkresult>"

    xml += "\n</checkresults>"

    return xml
174131
@Override
	public InputStream createResourceAsStream(GeneratorContext context) {

		String path = context.getPath();
		InputStream is = null;
		if (FileNameUtils.hasImageExtension(path)) {
			try {
				is = context.getResourceReaderHandler().getResourceAsStream(path, false);
			} catch (ResourceNotFoundException e) {
				// Nothing to do
			}
		}

		return is;
	}
209788
function buildXml()
    {
        $this->checkConnector();
        $this->checkRequest();

        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
        }

        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();

        if (!isset($_GET["fileName"])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);

        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);

        if (!file_exists($filePath) || !is_file($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
        }

        list($width, $height) = getimagesize($filePath);
        $oNode = new Ckfinder_Connector_Utils_XmlNode("ImageInfo");
        $oNode->addAttribute("width", $width);
        $oNode->addAttribute("height", $height);
        $this->_connectorNode->addChild($oNode);
    }
963249
def make_parser():
    
    p = xml.sax.make_parser()
    p.setFeature(xml.sax.handler.feature_namespaces, True)
    p.setFeature(xml.sax.handler.feature_external_ges, False)
    p.setProperty(xml.sax.handler.property_lexical_handler,
                  XMPPLexicalHandler)
    return p
663936
def create_from_xml(root, extdir=None):
        

        src_type = root.attrib['type']
        spec = utils.load_xml_elements(root, 'spectrum')
        spectral_pars = utils.load_xml_elements(root, 'spectrum/parameter')
        spectral_type = spec['type']
        spectral_pars = cast_pars_dict(spectral_pars)
        spat = {}
        spatial_pars = {}
        nested_sources = []

        if src_type == 'CompositeSource':
            spatial_type = 'CompositeSource'
            source_library = root.findall('source_library')[0]
            for node in source_library.findall('source'):
                nested_sources += [Source.create_from_xml(node, extdir=extdir)]
        else:
            spat = utils.load_xml_elements(root, 'spatialModel')
            spatial_pars = utils.load_xml_elements(
                root, 'spatialModel/parameter')
            spatial_pars = cast_pars_dict(spatial_pars)
            spatial_type = spat['type']

        xml_dict = copy.deepcopy(root.attrib)
        src_dict = {'catalog': xml_dict}

        src_dict['Source_Name'] = xml_dict['name']
        src_dict['SpectrumType'] = spectral_type
        src_dict['SpatialType'] = spatial_type
        src_dict['SourceType'] = src_type
        src_dict['Spatial_Filename'] = None
        src_dict['Spectrum_Filename'] = None
        if 'file' in spat:
            src_dict['Spatial_Filename'] = utils.xmlpath_to_path(spat['file'])
            if not os.path.isfile(src_dict['Spatial_Filename']) \
                    and extdir is not None:
                src_dict['Spatial_Filename'] = \
                    os.path.join(extdir, 'Templates',
                                 src_dict['Spatial_Filename'])

        if 'file' in spec:
            src_dict['Spectrum_Filename'] = utils.xmlpath_to_path(spec['file'])

        if src_type == 'PointSource':
            src_dict['SpatialModel'] = 'PointSource'
        elif src_type == 'CompositeSource':
            src_dict['SpatialModel'] = 'CompositeSource'
        elif spatial_type == 'SpatialMap':
            src_dict['SpatialModel'] = 'SpatialMap'
        else:
            src_dict['SpatialModel'] = spatial_type

        if src_type == 'PointSource' or \
                spatial_type in ['SpatialMap', 'RadialGaussian', 'RadialDisk']:

            if 'RA' in xml_dict:
                src_dict['RAJ2000'] = float(xml_dict['RA'])
                src_dict['DEJ2000'] = float(xml_dict['DEC'])
            elif 'RA' in spatial_pars:
                src_dict['RAJ2000'] = float(spatial_pars['RA']['value'])
                src_dict['DEJ2000'] = float(spatial_pars['DEC']['value'])
            else:
                try:
                    skydir = wcs_utils.get_map_skydir(os.path.expandvars(
                            src_dict['Spatial_Filename']))
                except Exception:
                    skydir = hpx_utils.get_map_skydir(os.path.expandvars(
                            src_dict['Spatial_Filename']))
                src_dict['RAJ2000'] = skydir.ra.deg
                src_dict['DEJ2000'] = skydir.dec.deg

            radec = np.array([src_dict['RAJ2000'], src_dict['DEJ2000']])

            src_dict['spectral_pars'] = spectral_pars
            src_dict['spatial_pars'] = spatial_pars
            return Source(src_dict['Source_Name'],
                          src_dict, radec=radec)

        elif src_type == 'DiffuseSource' and spatial_type == 'ConstantValue':
            return IsoSource(src_dict['Source_Name'],
                             {'Spectrum_Filename': spec['file'],
                              'spectral_pars': spectral_pars,
                              'spatial_pars': spatial_pars})
        elif src_type == 'DiffuseSource' and spatial_type == 'MapCubeFunction':
            return MapCubeSource(src_dict['Source_Name'],
                                 {'Spatial_Filename': spat['file'],
                                  'SpectrumType': spectral_type,
                                  'spectral_pars': spectral_pars,
                                  'spatial_pars': spatial_pars})
        elif src_type == 'CompositeSource':
            return CompositeSource(src_dict['Source_Name'],
                                   {'SpectrumType': spectral_type,
                                    'nested_sources': nested_sources})
        else:
            raise Exception(
                'Unrecognized type for source: %s %s' % (src_dict['Source_Name'], src_type))
938059
public static void prepareContext(GenericApplicationContext ctx)
  {
    final String configFileName = "annis-service.properties";
    
    MutablePropertySources sources = ctx.getEnvironment().getPropertySources();
    try
    {
      File fBase = new File(Utils.getAnnisFile(
        "conf/" + configFileName ).getAbsolutePath());
      if(fBase.canRead() && fBase.isFile())
      {
        sources.addFirst(new ResourcePropertySource("file:" + fBase.getCanonicalPath()));
      }
      
      String globalConfig = System.getenv("ANNIS_CFG");
      if(globalConfig == null)
      {
        globalConfig = "/etc/annis";
      }
      File fGlobal = new File(globalConfig + "/" + configFileName);
      if(fGlobal.canRead() && fGlobal.isFile())
      {
        sources.addFirst(new ResourcePropertySource("file:" + fBase.getCanonicalPath()));
      }
      
      String userConfig = System.getProperty("user.home") + "/.annis";
      File fUser = new File(userConfig + "/" + configFileName);
      if(fUser.canRead() && fUser.isFile())
      {
        sources.addFirst(new ResourcePropertySource("file:" + fUser.getCanonicalPath()));
      }
      
    }
    catch (IOException ex)
    {
      log.error("Could not load configuration", ex);
    }
  }