Try to process the Xinclude transformation

@param string  XML to process.

@return string
@throws BuildException On errors
554559
protected function process($xml)
    {
        if ($this->basedir) {
            $cwd = getcwd();
            chdir($this->basedir);
        }

        // Create and setup document.
        $xmlDom = new DomDocument();
        $xmlDom->resolveExternals = $this->resolveExternals;

        $xmlDom->loadXML($xml);

        $xmlDom->xinclude();

        if ($this->basedir) {
            chdir($cwd);
        }

        return $xmlDom->saveXML();
    }
545899
protected function buildXml()
	{
		$buffer = array();

		$buffer[] = '<?xml version="1.0"?>';
		$buffer[] = '<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
		$buffer[] = ' <database name="">';

		$buffer = array_merge($buffer, $this->buildXmlStructure());

		$buffer[] = ' </database>';
		$buffer[] = '</mysqldump>';

		return implode("\n", $buffer);
	}
840833
protected function transform(DOMDocument $document)
    {
        if (!$this->toDir->exists()) {
            throw new BuildException("Directory '" . $this->toDir . "' does not exist");
        }

        $xslfile = $this->getStyleSheet();

        $xsl = new DOMDocument();
        $xsl->load($xslfile->getAbsolutePath());

        $proc = new XSLTProcessor();
        if (defined('XSL_SECPREF_WRITE_FILE')) {
            $proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
        }
        $proc->registerPHPFunctions('nl2br');
        $proc->importStylesheet($xsl);
        $proc->setParameter('', 'output.sorttable', (string) $this->useSortTable);

        if ($this->format === "noframes") {
            $writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
            $writer->write($proc->transformToXml($document));
            $writer->close();
        } else {
            ExtendedFileStream::registerStream();

            $toDir = (string) $this->toDir;

            // urlencode() the path if we're on Windows
            if (FileSystem::getFileSystem()->getSeparator() === '\\') {
                $toDir = urlencode($toDir);
            }

            // no output for the framed report
            // it's all done by extension...
            $proc->setParameter('', 'output.dir', $toDir);
            $proc->transformToXml($document);

            ExtendedFileStream::unregisterStream();
        }
    }
423903
protected function buildXml()
    {
        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

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

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

        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
        $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["newFileName"]);

        $oRenamedFileNode = new Ckfinder_Connector_Utils_XmlNode("RenamedFile");
        $this->_connectorNode->addChild($oRenamedFileNode);
        $oRenamedFileNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName));

        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
        if (!$resourceTypeInfo->checkExtension($newFileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
        }

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

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

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

        if ($_config->forceAscii()) {
            $newFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($newFileName);
        }

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

        $bMoved = false;

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

        if (!is_writable(dirname($newFilePath))) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
        }

        if (!is_writable($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
        }

        if (file_exists($newFilePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
        }

        $bMoved = @rename($filePath, $newFilePath);

        if (!$bMoved) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File " . CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName) . "has not been renamed");
        } else {
            $oRenamedFileNode->addAttribute("newName", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($newFileName));

            $thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
            CKFinder_Connector_Utils_FileSystem::unlink($thumbPath);
        }
    }
1165755
public Api fromXML(String xml) throws Exception {
    // retrieve the JAXB wrapper representation from the xml received
    Api api = Api.fromXML(xml);
    // check whether an error code was sent
    Error error = api.getError();
    // if there is an error - handle it
    if (error != null) {
      // prepare the error message
      String errMsg = "error code=" + error.getCode() + " info:'"
          + error.getInfo() + "'";
      this.handleError(errMsg);
    }
    return api;
  }
100082
static function processNodeTransformationRoot( $useComments, $php, $tpl, &$node, &$resourceData )
    {
        $nodeType = $node[0];
        if ( $nodeType == eZTemplate::NODE_ROOT )
        {
            $children = $node[1];
            $newNode = array( $nodeType,
                              false );
            if ( $children )
            {
                $newChildren = array();
                foreach ( $children as $childNode )
                {
                    $newChildNode = eZTemplateCompiler::processNodeTransformationChild( $useComments, $php, $tpl, $childNode, $resourceData );
                    if ( !$newChildNode )
                        $newChildren[] = $childNode;
                    else
                        $newChildren = array_merge( $newChildren, $newChildNode );
                }
                if ( count( $newChildren ) > 0 )
                    $newNode[1] = $newChildren;
            }
            return $newNode;
        }
        else
            $tpl->error( 'processNodeTransformation', "Unknown root type $nodeType, should be " . eZTemplate::NODE_ROOT );
        return false;
    }
1161227
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    String prefix;
    String namespace;
    String methName;

    String fullName = m_arg0.execute(xctxt).str();
    int indexOfNSSep = fullName.indexOf(':');

    if (indexOfNSSep < 0)
    {
      prefix = "";
      namespace = Constants.S_XSLNAMESPACEURL;
      methName = fullName;
    }
    else
    {
      prefix = fullName.substring(0, indexOfNSSep);
      namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
      if (null == namespace)
        return XBoolean.S_FALSE;
        methName = fullName.substring(indexOfNSSep + 1);
    }

    if (namespace.equals(Constants.S_XSLNAMESPACEURL))
    {
      try
      {
        if (null == m_functionTable) m_functionTable = new FunctionTable();
        return m_functionTable.functionAvailable(methName) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
      }
      catch (Exception e)
      {
        return XBoolean.S_FALSE;
      }
    }
    else
    {
      //dml
      ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
      return extProvider.functionAvailable(namespace, methName)
             ? XBoolean.S_TRUE : XBoolean.S_FALSE;
    }
  }
597715
public static function transform($xslFileName, DOMDocument $xml)
    {
        $xsl = new DOMDocument;
        $xsl->load(__DIR__.'/../../xslt/'.$xslFileName.'.xsl');

        $proc = new XSLTProcessor;
        $proc->importStyleSheet($xsl);

        libxml_use_internal_errors(true);

        $result = $proc->transformToXML($xml);

        foreach (libxml_get_errors() as $error) {
            //throw new \Exception($error->message);
        }

        return $result;
    }
1136552
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    String fullName = m_arg0.execute(xctxt).str();
    int indexOfNSSep = fullName.indexOf(':');
    String result = null;
    String propName = "";

    // List of properties where the name of the
    // property argument is to be looked for.
    Properties xsltInfo = new Properties();

    loadPropertyFile(XSLT_PROPERTIES, xsltInfo);

    if (indexOfNSSep > 0)
    {
      String prefix = (indexOfNSSep >= 0)
                      ? fullName.substring(0, indexOfNSSep) : "";
      String namespace;

      namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
      propName = (indexOfNSSep < 0)
                 ? fullName : fullName.substring(indexOfNSSep + 1);

      if (namespace.startsWith("http://www.w3.org/XSL/Transform")
              || namespace.equals("http://www.w3.org/1999/XSL/Transform"))
      {
        result = xsltInfo.getProperty(propName);

        if (null == result)
        {
          warn(xctxt, XPATHErrorResources.WG_PROPERTY_NOT_SUPPORTED,
               new Object[]{ fullName });  //"XSL Property not supported: "+fullName);

          return XString.EMPTYSTRING;
        }
      }
      else
      {
        warn(xctxt, XPATHErrorResources.WG_DONT_DO_ANYTHING_WITH_NS,
             new Object[]{ namespace,
                           fullName });  //"Don't currently do anything with namespace "+namespace+" in property: "+fullName);

        try
        {
            //if secure procession is enabled only handle required properties do not not map any valid system property
            if(!xctxt.isSecureProcessing())
            {
                result = System.getProperty(propName);
            }
            else
            {
                warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
                        new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);
            }
            if (null == result)
            {
                return XString.EMPTYSTRING;
            }
        }
        catch (SecurityException se)
        {
          warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
               new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);

          return XString.EMPTYSTRING;
        }
      }
    }
    else
    {
      try
      {
          //if secure procession is enabled only handle required properties do not not map any valid system property
          if(!xctxt.isSecureProcessing())
          {
              result = System.getProperty(fullName);
          }
          else
          {
              warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
                      new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);
          }
          if (null == result)
          {
              return XString.EMPTYSTRING;
          }
      }
      catch (SecurityException se)
      {
        warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
             new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);

        return XString.EMPTYSTRING;
      }
    }

    if (propName.equals("version") && result.length() > 0)
    {
      try
      {
        // Needs to return the version number of the spec we conform to.
        return new XString("1.0");
      }
      catch (Exception ex)
      {
        return new XString(result);
      }
    }
    else
      return new XString(result);
  }
338106
public function FromXML($xml)
	{
		$sxo = new SimpleXMLElement($xml);
		
		if($sxo->encoding == "base64")
		{
			$this->Data = base64_decode($sxo->data);
		}
		else
		{
			$this->Data = $sxo->data;
		}
		
		$this->Name = $attachment->name;
		$this->Type = $attachment->type;
		$this->Size = $attachment->size;
		$this->Extension = $attachment->extension;
	}
1299985
protected function processReport($xmlString)
    {
        $xml = simplexml_load_string($xmlString);

        if ($xml === false) {
            $this->phpci->log($xmlString);
            throw new \Exception('Could not process PHPMD report XML.');
        }

        $warnings = 0;

        foreach ($xml->file as $file) {
            $fileName = (string)$file['name'];
            $fileName = str_replace($this->phpci->buildPath, '', $fileName);

            foreach ($file->violation as $violation) {
                $warnings++;

                $this->build->reportError(
                    $this->phpci,
                    'php_mess_detector',
                    (string)$violation,
                    PHPCI\Model\BuildError::SEVERITY_HIGH,
                    $fileName,
                    (int)$violation['beginline'],
                    (int)$violation['endline']
                );
            }
        }

        return $warnings;
    }
1342951
public void transform(XmlNode node, StringBuilder builder) {
        switch (node.getType()) {
            case XmlNode.ELEMENT_NODE: {
                builder.append("<");
                builder.append(node.getName());
                for (XmlNode attribute : node.getAttributes().values()) {
                    transform(attribute, builder);
                }
                builder.append(">");
                for (XmlNode child : node.getChildren()) {
                    transform(child, builder);
                }
                builder.append("</");
                builder.append(node.getName());
                builder.append(">");
            }
                break;
            case XmlNode.ATTRIBUTE_NODE: {
                builder.append(" ");
                builder.append(node.getName());
                builder.append("=\"");
                builder.append(node.getValue());
                builder.append("\"");
            }
                break;
            case XmlNode.TEXT_NODE: {
                builder.append(node.getValue());
            }
        }
    }
929486
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    int context = getArg0AsNode(xctxt);
    if(DTM.NULL == context)
      return XString.EMPTYSTRING;
    DTM dtm = xctxt.getDTM(context);
    String s = (context != DTM.NULL) ? dtm.getLocalName(context) : "";
    if(s.startsWith("#") || s.equals("xmlns"))
      return XString.EMPTYSTRING;

    return new XString(s);
  }
768669
@Override
    public void execute() throws BuildException {
        /*
         * A couple of the sample properties used in the download XML come from the Readme.html file and need the HTML elements stripped out before we can write the XML using the
         * supertype
         */
        String sampleName = null;
        String sampleAbstract = null;
        String readmeContent = null;

        // Parse the source readme file for the abstract, as it exists only in here
        try {
            Document doc = Jsoup.parse(sourceReadmeFile, "UTF-8");
            //Short abstract description is used by the tools (via download XML - "description"), and WASDev via wasdev.xml.
            Element abstractElement = getRequiredElementById(doc, "ibm-wasdev-sample-abstract-content");
            sampleAbstract = abstractElement.text();
            this.setDescription(abstractElement.text());

        } catch (IOException e) {
            // Can't read the readme so can't produce the XML
            throw new BuildException("Unable to load the Readme.html from " + sourceReadmeFile.getAbsolutePath() + " due to IOException: " + e.getMessage(), e);
        }

        // Parse the built readme file for everything else
        try {
            Document doc = Jsoup.parse(builtReadmeFile, "UTF-8");
            Element nameElement = getRequiredElementById(doc, "ibm-wasdev-sample-name-title");
            sampleName = nameElement.text();
            this.setName(sampleName);

            // Several nodes aren't needed for the WASDev page
            removeElementIfExistsById(doc, "ibm-wasdev-sample-name-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-desc-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-external-deps-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-external-deps-content");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-abstract-content");
            removeElementIfExistsById(doc, "ibm-title-support-info");
            removeElementIfExistsById(doc, "ibm-support-info");
            removeElementIfExistsById(doc, "ibmLicenseFlowing");

            Element readmeElement = getRequiredElementById(doc, "ibm-wasdev-sample-readme-content");

            // If the source is supplied append it to the description
            if (this.sourceFilePath != null) {
                File sourceFile = new File(this.sourceFilePath);
                if (sourceFile.exists()) {
                    BufferedReader br = null;
                    try {
                        br = new BufferedReader(new FileReader(sourceFile));
                        Element sourceNode = new Element(Tag.valueOf("code"), "");
                        String line = null;
                        while ((line = br.readLine()) != null) {
                            // Add nice spacing in the HTML, first tabs to spaces
                            line = line.replaceAll("\\t", "    ");
                            while (line.startsWith(" ")) {
                                line = line.substring(1);
                                sourceNode.append("&nbsp;");
                            }
                            sourceNode.appendText(line);
                            sourceNode.append("<br/>");
                        }
                        readmeElement.appendChild(sourceNode);
                    } finally {
                        if (br != null) {
                            br.close();
                        }
                    }
                }
            }
            readmeContent = readmeElement.html();
        } catch (IOException e) {
            // Can't read the readme so can't produce the XML
            throw new BuildException("Unable to load the Readme.html from " + builtReadmeFile.getAbsolutePath() + " due to IOException: " + e.getMessage(), e);
        }

        // All processing done (everything is set by ANT) so let the supertype generate the XML
        super.execute();

        // We also need to generate a properties file and a description.html with content used to populate Massive
        // First the properties file
        File propertiesFile = new File(this.propertiesFilePath);
        Properties assetInfoProps = new Properties();
        if (propertiesFile.exists()) {
            // Append to an existing props
            FileInputStream in = null;
            try {
                in = new FileInputStream(propertiesFile);
                assetInfoProps.load(in);
            } catch (FileNotFoundException e) {
                throw new BuildException(e);
            } catch (IOException e) {
                throw new BuildException(e);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                        throw new BuildException(e);
                    }
                }
            }
        }
        assetInfoProps.put("name", sampleName);
        assetInfoProps.put("shortDescription", sampleAbstract);
        assetInfoProps.put("downloadURL", assetDownloadUrl);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(propertiesFile);
            assetInfoProps.store(out, null);
        } catch (FileNotFoundException e) {
            throw new BuildException(e);
        } catch (IOException e) {
            throw new BuildException(e);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            }
        }

        // In the same directory as the properties file, write the description.html file
        File descriptionFile = new File(propertiesFile.getParentFile(), "description.html");
        Writer descriptionWriter = null;
        try {
            descriptionWriter = new OutputStreamWriter(new FileOutputStream(descriptionFile), StandardCharsets.UTF_8);
            descriptionWriter.write(readmeContent);
        } catch (IOException e) {
            throw new BuildException(e);
        } finally {
            if (descriptionWriter != null) {
                try {
                    descriptionWriter.close();
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            }
        }
    }
1157246
@Override
    public void processXML()
                    throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processXML");

        // Process all of the corresponding XML types in no particular
        // order other than it is the same as in prior releases.

        List<? extends EnvEntry> envEntries = ivNameSpaceConfig.getEnvEntries();
        if (envEntries != null)
        {
            processXMLEnvEntries(envEntries);
        }

        List<? extends ResourceRef> resourceRefs = ivNameSpaceConfig.getResourceRefs();
        if (resourceRefs != null)
        {
            processXMLResourceRefs(resourceRefs);
        }

        List<? extends ResourceEnvRef> resourceEnvRefs = ivNameSpaceConfig.getResourceEnvRefs();
        if (resourceEnvRefs != null)
        {
            processXMLResourceEnvRefs(resourceEnvRefs);
        }

        List<? extends MessageDestinationRef> msgDestRefs = ivNameSpaceConfig.getMsgDestRefs();
        if (msgDestRefs != null)
        {
            processXMLMsgDestRefs(msgDestRefs);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processXML");
    }
204894
public static function toXml($xml)
    {
        if ($xml instanceof XmlBuilder) {
            return $xml->getDom();
        }
        if ($xml instanceof \DOMDocument) {
            return $xml;
        }
        $dom = new \DOMDocument();
        $dom->preserveWhiteSpace = false;
        if ($xml instanceof \DOMNode) {
            $xml = $dom->importNode($xml, true);
            $dom->appendChild($xml);
            return $dom;
        }

        if (is_array($xml)) {
            return self::arrayToXml($dom, $dom, $xml);
        }
        if (!empty($xml)) {
            $dom->loadXML($xml);
        }
        return $dom;
    }
210372
protected function processTiles(\SimpleXMLElement $xml) {
        $namespace = '';                                            // default is the global namespace

        if ($tiles = $xml->xpath('/struts-config/tiles') ?: []) {
            $tiles = $tiles[0];

            // attribute class="%ClassName" #IMPLIED
            if (isset($tiles['class'])) {
                $class   = trim((string) $tiles['class']);
                $classes = $this->resolveClassName($class);
                if (!$classes)            throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Class not found.');
                if (sizeof($classes) > 1) throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Ambiguous class name, found "'.join('", "', $classes).'".');
                $this->setTilesClass($classes[0]);
            }

            // attribute namespace="%ResourcePath" #IMPLIED
            if (isset($tiles['namespace'])) {
                $namespace = trim((string) $tiles['namespace']);
                $namespace = str_replace('/', '\\', $namespace);

                if ($namespace == '\\') {
                    $namespace = '';
                }
                else if (strlen($namespace)) {
                    if (!$this->isValidNamespace($namespace)) throw new StrutsConfigException('<tiles namespace="'.$tiles['namespace'].'": Invalid namespace');
                    if (strStartsWith($namespace, '\\')) $namespace  = substr($namespace, 1);
                    if (!strEndsWith($namespace, '\\'))  $namespace .= '\\';
                }
            }
        }
        $this->viewNamespace = $namespace;

        $elements = $xml->xpath('/struts-config/tiles/tile') ?: [];

        foreach ($elements as $tag) {
            $this->tilesContext = [];
            $name = (string) $tag['name'];
            $this->getTile($name, $xml);
        }
    }