Parses the file at the given location and creates a {@link Document} instance to read the rules from.

@param location location of the XML file
@return {@link Document} instance representing the XML file
338664
private Document buildDocument(String location) {
        try {
            return documentBuilderFactory.newDocumentBuilder().parse(ClassPathResource.asInputStream(location));
        } catch (ParserConfigurationException | SAXException | IOException | RuntimeException e) {
            throw new XmlRuleSetException("Could not parse RuleSet from given location '" + location + "'.", e);
        }
    }
31470
protected void parseConfigurationGroup(I_CmsXmlContentLocation location) {

        List<I_CmsXmlContentValueLocation> locations = location.getSubValues(N_CONFIGURATION);
        m_currentConfigurationGroup = new HashMap<String, CmsContainerConfiguration>();
        m_results.put(m_currentLocale, m_currentConfigurationGroup);
        for (I_CmsXmlContentValueLocation configLocation : locations) {
            parseSingleConfiguration(configLocation);
        }
    }
1257457
public static String getClusterForLocation(URI location) {
        Matcher matcher = getLocatorMatcher(location);
        checkArgument(matcher.matches(), "Invalid location: %s", location);

        final String clusterPrefix;

        if (matcher.group("universe") != null) {
            clusterPrefix = matcher.group("universe");
        } else {
            clusterPrefix = "local";
        }

        String group = Objects.firstNonNull(matcher.group("group"), DEFAULT_GROUP);
        return format("%s_%s", clusterPrefix, group);
    }
919565
private void parseResponse(InputStream inputStream) {

        try {
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(inputStream);
            doc.getDocumentElement().normalize();

            NodeList nodes = doc.getElementsByTagName("place");

            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);

                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    Element element = (Element) node;
                    _woeid = getValue("woeid", element);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
664612
@Requires("location != null")
  public List<? extends File> getLocation(Location location) {
    Iterable<? extends File> path = fileManager.getLocation(location);
    if (path == null) {
      return null;
    }

    ArrayList<File> locations = new ArrayList<File>();
    for (File entry : path) {
      locations.add(entry);
    }
    return locations;
  }
377539
@Override
    public XMLEvent allocate(XMLStreamReader r) throws XMLStreamException
    {
        Location loc;

        // Need to keep track of accurate location info?
        if (mAccurateLocation) {
            loc = r.getLocation();
        } else {
            loc = mLastLocation;
            /* And even if we can just share one instance, we need that
             * first instance...
             */
            if (loc == null) {
                loc = mLastLocation = r.getLocation();
            }
        }

        switch (r.getEventType()) {
        case CDATA:
            return new CharactersEventImpl(loc, r.getText(), true);
        case CHARACTERS:
            return new CharactersEventImpl(loc, r.getText(), false);
        case COMMENT:
            return new CommentEventImpl(loc, r.getText());
        case DTD:
            // Not sure if we really need this defensive coding but...
            if (r instanceof XMLStreamReader2) {
                XMLStreamReader2 sr2 = (XMLStreamReader2) r;
                DTDInfo dtd = sr2.getDTDInfo();
                return new WDTD(loc,
                                dtd.getDTDRootName(),
                                dtd.getDTDSystemId(), dtd.getDTDPublicId(),
                                dtd.getDTDInternalSubset(),
                                (DTDSubset) dtd.getProcessedDTD());
            }
            /* No way to get all information... the real big problem is
             * that of how to access root name: it's obligatory for
             * DOCTYPE construct. :-/
             */
            return new WDTD(loc, null, r.getText());

        case END_DOCUMENT:
            return new EndDocumentEventImpl(loc);

        case END_ELEMENT:
            return new EndElementEventImpl(loc, r);

        case PROCESSING_INSTRUCTION:
            return new ProcInstrEventImpl(loc, r.getPITarget(), r.getPIData());
        case SPACE:
            {
                CharactersEventImpl ch = new CharactersEventImpl(loc, r.getText(), false);
                ch.setWhitespaceStatus(true);
                return ch;
            }
        case START_DOCUMENT:
            return new StartDocumentEventImpl(loc, r);

        case START_ELEMENT:
            {
                /* Creating the event is bit complicated, as the stream
                 * reader is not to know anything about event objects.
                 * To do this, we do double-indirection, which means that
                 * this object actually gets a callback:
                 */
                /* 19-Jul-2006, TSa: WSTX-61 points out that the code was
                 *   assuming it's always Woodstox reader we had... not
                 *   necessarily so.
                 */
                if (r instanceof StreamReaderImpl) {
                    StreamReaderImpl sr = (StreamReaderImpl) r;
                    BaseStartElement be = (BaseStartElement) sr.withStartElement(this, loc);
                    if (be == null) { // incorrect state
                        throw new WstxException("Trying to create START_ELEMENT when current event is "
                                                +ErrorConsts.tokenTypeDesc(sr.getEventType()),
                                                loc);
                    }
                    return be;
                }
                /* Ok, not woodstox impl, will be bit more work (plus less
                 * efficient, and may miss some info)... but can be done.
                 */
                NamespaceContext nsCtxt = null;
                if (r instanceof XMLStreamReader2) {
                    nsCtxt = ((XMLStreamReader2) r).getNonTransientNamespaceContext();
                }
                Map<QName,Attribute> attrs;
                {
                    int attrCount = r.getAttributeCount();
                    if (attrCount < 1) {
                        attrs = null;
                    } else {
                        attrs = new LinkedHashMap<QName, Attribute>();
                        for (int i = 0; i < attrCount; ++i) {
                            QName aname = r.getAttributeName(i);
                            attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i)));
                        }
                    }
                }
                List<Namespace> ns;
                {
                    int nsCount = r.getNamespaceCount();
                    if (nsCount < 1) {
                        ns = null;
                    } else {
                        ns = new ArrayList<Namespace>(nsCount);
                        for (int i = 0; i < nsCount; ++i) {
                            ns.add(NamespaceEventImpl.constructNamespace(loc, r.getNamespacePrefix(i), r.getNamespaceURI(i)));
                        }
                    }
                }
                
                return SimpleStartElement.construct(loc, r.getName(), attrs, ns, nsCtxt);
            }

        case ENTITY_REFERENCE:
            {
                /* 19-Jul-2006, TSa: Let's also allow other impls, although
                 *   we can't get actual declaration if so...
                 */
                if (r instanceof StreamReaderImpl) {
                    EntityDecl ed = ((StreamReaderImpl) r).getCurrentEntityDecl();
                    if (ed == null) { // undefined?
                    // We'll still know the name though...
                        return new WEntityReference(loc, r.getLocalName());
                    }
                    return new WEntityReference(loc, ed);
                }
                return new WEntityReference(loc, r.getLocalName());
            }


            /* Following 2 types should never get in here; they are directly
             * handled by DTDReader, and can only be accessed via DTD event
             * element.
             */
        case ENTITY_DECLARATION:
        case NOTATION_DECLARATION:
            /* Following 2 types should never get in here; they are directly
             * handled by the reader, and can only be accessed via start
             * element.
             */
        case NAMESPACE:
        case ATTRIBUTE:
            throw new WstxException("Internal error: should not get "
                                    +ErrorConsts.tokenTypeDesc(r.getEventType()));
        default:
            throw new IllegalStateException("Unrecognized event type "+r.getEventType()+".");
        }
    }
1352052
public static Environment of(@NonNull String location) {
        if (location.startsWith(PREFIX_CLASSPATH)) {
            location = location.substring(PREFIX_CLASSPATH.length());
            return loadClasspath(location);
        } else if (location.startsWith(PREFIX_FILE)) {
            location = location.substring(PREFIX_FILE.length());
            return of(new File(location));
        } else if (location.startsWith(PREFIX_URL)) {
            location = location.substring(PREFIX_URL.length());
            try {
                return of(new URL(location));
            } catch (MalformedURLException e) {
                log.error("", e);
                return null;
            }
        } else {
            return loadClasspath(location);
        }
    }
978003
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    int whereNode = getArg0AsNode(xctxt);
    String fileLocation = null;

    if (DTM.NULL != whereNode)
    {
      DTM dtm = xctxt.getDTM(whereNode);
      
      // %REVIEW%
      if (DTM.DOCUMENT_FRAGMENT_NODE ==  dtm.getNodeType(whereNode))
      {
        whereNode = dtm.getFirstChild(whereNode);
      }

      if (DTM.NULL != whereNode)
      {        
        fileLocation = dtm.getDocumentBaseURI();
//        int owner = dtm.getDocument();
//        fileLocation = xctxt.getSourceTreeManager().findURIFromDoc(owner);
      }
    }

    return new XString((null != fileLocation) ? fileLocation : "");
  }
727236
private static Feature createLocation(final Point point,
            final LocationType locationType) {
        final Feature location = new Feature();
        location.setGeometry(point);
        location.setProperty("locationType", locationType);
        location.setId("location");
        return location;
    }
1006147
public Map<String, String> parseXmlConfiguration(final String path) {
    File xmlFile;
    xmlFile = new File(path);
    if (!xmlFile.exists()) {
      System.err.format("File %s does not exist.", path);
      return null;
    }
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder;
    try {
      docBuilder = docBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
      System.err.format("Failed to create instance of DocumentBuilder for file: %s. %s. %n",
          path, e.getMessage());
      return null;
    }
    Document doc;
    try {
      doc = docBuilder.parse(xmlFile);
    } catch (IOException e) {
      System.err.format("An I/O error occured reading file %s. %s.%n", path, e.getMessage());
      return null;
    } catch (SAXException e) {
      System.err.format("A parsing error occured parsing file %s. %s.%n", path, e.getMessage());
      return null;
    }
    // Optional, but recommended.
    // Refer to http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
    doc.getDocumentElement().normalize();
    Map<String, String> ret = new HashMap<>();
    NodeList propNodeList = doc.getElementsByTagName("property");
    for (int i = 0; i < propNodeList.getLength(); i++) {
      Node propNode = propNodeList.item(i);
      if (propNode.getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) propNode;
        ret.put(element.getElementsByTagName("name").item(0).getTextContent(),
            element.getElementsByTagName("value").item(0).getTextContent());
      }
    }
    return ret;
  }
961056
public static InputStream getResource(String location) throws ResourceNotFoundException {
        if (StringUtils.isEmpty(location)) {
            throw new NullPointerException("location must not be null");
        }
        log.debug("获取资源[{}]", location);
        try {
            if (location.startsWith(ResourceProtocol.FILE.protocol)) {
                return new FileInputStream(
                    new File(location.substring(ResourceProtocol.FILE.protocol.length())));
            } else if (location.startsWith(ResourceProtocol.URL.protocol)) {
                return new URL(location.substring(ResourceProtocol.URL.protocol.length()))
                    .openStream();
            } else if (location.startsWith(ResourceProtocol.HTTP.protocol)) {
                return new URL(location.substring(ResourceProtocol.HTTP.protocol.length()))
                    .openStream();
            } else if (location.startsWith(ResourceProtocol.HTTPS.protocol)) {
                return new URL(location.substring(ResourceProtocol.HTTPS.protocol.length()))
                    .openStream();
            } else {
                if (location.startsWith(ResourceProtocol.CLASSPATH.protocol)) {
                    location = location.substring(ResourceProtocol.CLASSPATH.protocol.length());
                }
                return Thread.currentThread().getContextClassLoader().getResourceAsStream(location);
            }
        } catch (Throwable e) {
            log.error("资源[{}]获取失败", location, e);
            throw new ResourceNotFoundException("查找资源[" + location + "]异常", e);
        }
    }
1170189
@Override
	public void findLocation(final String location) {
		showAlternativesView(false);
		GwtCommand command = new GwtCommand(GetLocationForStringRequest.COMMAND);
		GetLocationForStringRequest request = new GetLocationForStringRequest();
		request.setCrs(mapPresenter.getViewPort().getCrs());
		request.setLocation(location);
		request.setServicePattern(servicePattern);
		command.setCommandRequest(request);
		GeomajasServerExtension.getInstance().getCommandService().execute(command,
				new AbstractCommandCallback<GetLocationForStringResponse>() {
			public void execute(GetLocationForStringResponse response) {
				goToLocation(response, location);
			}
		});
	}
490247
public static XSLTTransformationFileSystem usingFilesystem(String location)
    {
        XSLTTransformation tansformation = new XSLTTransformation();
        tansformation.template = location;
        return tansformation;
    }
1352818
public SourceLocation substringLocation(int start, int end) {
    checkElementIndex(start, rawText.length(), "start");
    checkArgument(start < end);
    checkArgument(end <= rawText.length());
    if (offsets == null) {
      return getSourceLocation();
    }
    return new SourceLocation(
        getSourceLocation().getFilePath(),
        offsets.getPoint(rawText, start),
        // source locations are inclusive, the end locations should point at the last character
        // in the string, whereas substring is usually specified exclusively, so subtract 1 to make
        // up the difference
        offsets.getPoint(rawText, end - 1));
  }
1237428
def location_xml
      location = REXML::Element.new('location')
      location.add_element('building').text = @building
      location.add_element('department').text = @department
      location.add_element('email_address').text = @email_address
      location.add_element('position').text = @position
      location.add_element('phone').text = @phone
      location.add_element('real_name').text = @real_name
      location.add_element('room').text = @room
      location.add_element('username').text = @username
      return location
    end
881156
@Nullable
  public static Location getParent(Location location) {
    URI source = location.toURI();

    // If it is root, return null
    if ("/".equals(source.getPath())) {
      return null;
    }

    URI resolvedParent = URI.create(source.toString() + "/..").normalize();
    return location.getLocationFactory().create(resolvedParent);
  }
732235
public static URI toURI(String location) throws UtilException {
		try {
			return new URI(location.replace(" ", "%20"));
		} catch (URISyntaxException e) {
			throw new UtilException(e);
		}
	}