Java Code Examples for org.dom4j.Document#selectSingleNode()

The following examples show how to use org.dom4j.Document#selectSingleNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JUnitReportGenerator.java    From gocd with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Document doc = new SAXReader().read(new FileInputStream(new File("/home/cruise/sample_junit.xml")));
    Element suite = (Element) doc.selectSingleNode("//testsuite");
    Element rootElement = doc.getRootElement();
    for (int i = 0; i < 50000; i++) {
        Element copy = suite.createCopy();
        setAttr(i, copy, "name");
        setAttr(i, copy, "hostname");
        List<Element> elements = copy.selectNodes(".//testcase");
        for (Element element : elements) {
            setAttr(i, element, "classname");
            setAttr(i, element, "name");
        }
        rootElement.add(copy);
    }
    FileUtils.writeStringToFile(new File("/tmp/repo/imagine.xml"), doc.asXML(), UTF_8);
}
 
Example 2
Source File: Parser.java    From ParsePDM with Apache License 2.0 6 votes vote down vote up
public PDM pdmParser(String pdmFileName) throws Exception {
    SAXReader reader = new SAXReader();
    Document doc = reader.read(pdmFileName);
          
    Node model = doc.selectSingleNode("//c:Children/o:Model");

    pdm.setId(((Element) model).attributeValue("Id"));
    pdm.setName(model.selectSingleNode("a:Name").getText());
    pdm.setCode(model.selectSingleNode("a:Code").getText());

    Node dbms = model.selectSingleNode("//o:Shortcut");
    pdm.setDBMSCode(dbms.selectSingleNode("a:Code").getText());
    pdm.setDBMSName(dbms.selectSingleNode("a:Name").getText());

    System.out.println("解析PDM为:" + pdm.getCode() + "(" + pdm.getName() + ")  DBMS为:" + pdm.getDBMSCode() + "(" + pdm.getDBMSName() + ")");

    pdm.setUsers(pdmUserParser(model));
    pdm.setTables(pdmTableParser(model));
    pdm.setPhysicalDiagrams(pdmPhysicalDiagramParser(model));
    pdm.setReferences(pdmReferenceParser(model));

    return pdm;
}
 
Example 3
Source File: CmisServiceImpl.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
private DataSourceRepository getConfiguration(String site, String cmisRepo) throws CmisRepositoryNotFoundException {
    String configPath = Paths.get(getConfigLocation()).toString();
    Document document =  null;
    DataSourceRepository repositoryConfig = null;
    try {
        document = contentService.getContentAsDocument(site, configPath);
        Node node = document.selectSingleNode(REPOSITORY_CONFIG_XPATH.replace(CMIS_REPO_ID_VARIABLE, cmisRepo));
        if (node != null) {
            repositoryConfig = new DataSourceRepository();
            repositoryConfig.setId(getPropertyValue(node, ID_PROPERTY));
            repositoryConfig.setType(getPropertyValue(node, TYPE_PROPERTY));
            repositoryConfig.setUrl(getPropertyValue(node, URL_PROPERTY));
            repositoryConfig.setUsername(getPropertyValue(node, USERNAME_PROPERTY));
            repositoryConfig.setPassword(getPropertyValue(node, PASSWORD_PROPERTY));
            repositoryConfig.setBasePath(getPropertyValue(node, BASE_PATH_PROPERTY));
            repositoryConfig.setDownloadUrlRegex(getPropertyValue(node, DOWNLOAD_URL_REGEX_PROPERTY));
            repositoryConfig.setUseSsl(Boolean.parseBoolean(getPropertyValue(node, USE_SSL_PROPERTY)));
        } else {
            throw new CmisRepositoryNotFoundException();
        }
    } catch (DocumentException e) {
        logger.error("Error while getting configuration for site: " + site + " cmis: " + cmisRepo +
                " (config path: " + configPath + ")");
    }
    return repositoryConfig;
}
 
Example 4
Source File: AlipaySubmit.java    From jframe with Apache License 2.0 6 votes vote down vote up
/**
    * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
    * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
    * @return 时间戳字符串
    * @throws Exception 
    * @throws UnsupportedEncodingException 
    * @throws IOException
    * @throws DocumentException
    * @throws MalformedURLException
    */
public static Map<String,String> parseRespose(String reponse) throws Exception {
	Map<String,String> respMap = new HashMap<String,String>();
	
	try {
		SAXReader reader = new SAXReader();
		Document doc = reader.read(new ByteArrayInputStream(reponse.getBytes("GBK")));
		Node isSuccessNode = doc.selectSingleNode("//alipay/is_success");
		if (isSuccessNode.getText().equals("T")) {
		    // 判断是否有成功标示
		    Node tradeStatusNode = doc.selectSingleNode("//response/trade/trade_status");
		    respMap.put("trade_status", tradeStatusNode.getText());
		}
		respMap.put("is_success", isSuccessNode.getText());
	} catch (Exception e) {
		LOG.error(e.getMessage(),reponse);
	}
	
	return respMap;
   }
 
Example 5
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the value of the specified attribute of the node determined by the given xpath.
 * 
 * @param doc      The XML document
 * @param xpath    The xpath selecting the node whose attribute we want
 * @param attrName The name of the attribute
 * @return The attribute value
 */
private String getAttrValue(Document doc, String xpath, String attrName)
{
	Node node = doc.selectSingleNode(xpath);

	if (node instanceof Attribute)
	{
		// we ignore the attribute name then
		return ((Attribute)node).getValue();
	}
	else if (node != null)
	{
		return node.valueOf("@" + attrName);
	}
    else
    {
        return null;
    }
}
 
Example 6
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the value of the specified attribute of the node determined by the given xpath.
 * 
 * @param doc      The XML document
 * @param xpath    The xpath selecting the node whose attribute we want
 * @param attrName The name of the attribute
 * @return The attribute value
 */
private String getAttrValue(Document doc, String xpath, String attrName)
{
	Node node = doc.selectSingleNode(xpath);

	if (node instanceof Attribute)
	{
		// we ignore the attribute name then
		return ((Attribute)node).getValue();
	}
	else if (node != null)
	{
		return node.valueOf("@" + attrName);
	}
    else
    {
        return null;
    }
}
 
Example 7
Source File: JobDeploymentDescriptor.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Load.
 * 
 * @param is the is
 * 
 * @throws DocumentException the document exception
 */
public void load(InputStream is) throws DocumentException{
	SAXReader reader = new org.dom4j.io.SAXReader();
    Document document = null;
    
   	document = reader.read(is);		
    
    Node job = document.selectSingleNode("//etl/job");
    if (job != null) {
    	this.project = job.valueOf("@project");
    	this.language = job.valueOf("@language");
    }
}
 
Example 8
Source File: PluginMetadataHelper.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of an element selected via an xpath expression from
 * a Plugin's plugin.xml file.
 *
 * @param pluginDir the path of the plugin directory.
 * @param xpath     the xpath expression.
 * @return the value of the element selected by the xpath expression.
 */
static String getElementValue( Path pluginDir, String xpath )
{
    if ( pluginDir == null )
    {
        return null;
    }
    try
    {
        final Path pluginConfig = pluginDir.resolve( "plugin.xml" );
        if ( Files.exists( pluginConfig ) )
        {
            final SAXReader saxReader = new SAXReader();
            saxReader.setEntityResolver(new EntityResolver() {
                @Override
                public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
                    throw new IOException("External entity denied: " + publicId + " // " + systemId);
                }
            });
            saxReader.setEncoding( "UTF-8" );
            final Document pluginXML = saxReader.read( pluginConfig.toFile() );
            final Element element = (Element) pluginXML.selectSingleNode( xpath );
            if ( element != null )
            {
                return element.getTextTrim();
            }
        }
    }
    catch ( Exception e )
    {
        Log.error( "Unable to get element value '{}' from plugin.xml of plugin in '{}':", xpath, pluginDir, e );
    }
    return null;
}
 
Example 9
Source File: JobDeploymentDescriptor.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Load.
 * 
 * @param is the is
 * 
 * @throws DocumentException the document exception
 */
public void load(InputStream is) throws DocumentException{
	SAXReader reader = new org.dom4j.io.SAXReader();
    Document document = null;
    
   	document = reader.read(is);		
    
    Node job = document.selectSingleNode("//etl/job");
    if (job != null) {
    	this.project = job.valueOf("@project");
    	this.language = job.valueOf("@language");
    }
}
 
Example 10
Source File: PluginLoader.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Node findMessageNode(List<Document> messageCollectionList, String xpath, String missingMsg)
        throws PluginException {
    for (Document document : messageCollectionList) {
        Node node = document.selectSingleNode(xpath);
        if (node != null) {
            return node;
        }
    }
    throw new PluginException(missingMsg);
}
 
Example 11
Source File: PluginLoader.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String findMessageText(List<Document> messageCollectionList, String xpath, String missingMsg) {
    for (Document document : messageCollectionList) {
        Node node = document.selectSingleNode(xpath);
        if (node != null) {
            return node.getText().trim();
        }
    }
    return missingMsg;
}
 
Example 12
Source File: XFormDecoder.java    From boubei-tss with Apache License 2.0 5 votes vote down vote up
/**
 * 将XML格式的数据设置到新创建的实体中
 * 
 * @param dataXml
 * @param entityClass
 * @return
 * @throws Exception
 */
public static Object decode(String dataXml, Class<?> entityClass) {
	Object bean = BeanUtil.newInstance(entityClass);
	if (dataXml != null) {
		Document doc = XMLDocUtil.dataXml2Doc(dataXml);
		Element dataNode = (Element) doc.selectSingleNode(XFORM_DATA_ROW_NODE_XPATH);
		BeanUtil.setDataToBean(bean, XMLDocUtil.dataNodes2Map(dataNode));
	}
	return bean;
}
 
Example 13
Source File: ImsRepositoryResolver.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * (non-Javadoc)
 * 
 */
@Override
public Element getObjectBank(final String ident) {
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    final VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
    final VFSItem vfsQTI = vfsUnzippedRoot.resolve(ident + ".xml");
    // getDocument(..) ensures that InputStream is closed in every case.
    final Document theDoc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    // if doc is null an error loading the document occured (IOException, qti.xml does not exist)
    if (theDoc == null) {
        return null;
    }
    final Element objectBank = (Element) theDoc.selectSingleNode("questestinterop/objectbank");
    return objectBank;
}
 
Example 14
Source File: RemoteArticleService.java    From boubei-tss with Apache License 2.0 5 votes vote down vote up
public void importArticle(String articleXml, Long channelId) {
    Document doc = XMLDocUtil.dataXml2Doc(articleXml);
    Element articleNode = (Element) doc.selectSingleNode("//ArticleInfo/Article");
    Article article = new Article();
    BeanUtil.setDataToBean(article, XMLDocUtil.dataNodes2Map(articleNode));
    
    Channel channel = channelDao.getEntity(channelId);
    article.setChannel(channel);
     
    //设置过期时间
    article.setOverdueDate(ArticleHelper.calculateOverDate(channel));
    
    articleDao.saveArticle(article);
}
 
Example 15
Source File: ImsRepositoryResolver.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * (non-Javadoc)
 * 
 */
@Override
public Element getObjectBank(final String ident) {
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    final VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
    final VFSItem vfsQTI = vfsUnzippedRoot.resolve(ident + ".xml");
    // getDocument(..) ensures that InputStream is closed in every case.
    final Document theDoc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    // if doc is null an error loading the document occured (IOException, qti.xml does not exist)
    if (theDoc == null) {
        return null;
    }
    final Element objectBank = (Element) theDoc.selectSingleNode("questestinterop/objectbank");
    return objectBank;
}
 
Example 16
Source File: AbstractElementNode.java    From boubei-tss with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected Document parse(String definition, String elementName) {
       Document doc = XMLDocUtil.dataXml2Doc(definition);
       
       org.dom4j.Node htmlNode    = doc.selectSingleNode("/" + elementName + "/html");
       org.dom4j.Node scriptNode  = doc.selectSingleNode("/" + elementName + "/script");
       org.dom4j.Node styleNode   = doc.selectSingleNode("/" + elementName + "/style");
       
       this.html   = XMLDocUtil.getNodeText(htmlNode);
       this.script = XMLDocUtil.getNodeText(scriptNode);
       this.style  = XMLDocUtil.getNodeText(styleNode);
       
       List<org.dom4j.Element> eventNodes = XMLDocUtil.selectNodes(doc, "/" + elementName + "/events/attach");
       eventNodes = (List<Element>) EasyUtils.checkNull(eventNodes, new ArrayList<org.dom4j.Element>());
       for( org.dom4j.Element eventNode : eventNodes ){
           this.events.put(eventNode.attributeValue("event"), eventNode.attributeValue("onevent"));
       }   
       
       List<org.dom4j.Element> paramNodes = XMLDocUtil.selectNodes(doc, "/" + elementName + "/parameters/param");
       paramNodes = (List<Element>) EasyUtils.checkNull(paramNodes, new ArrayList<org.dom4j.Element>());
       for( org.dom4j.Element paramNode : paramNodes ){
           String attrName = paramNode.attributeValue("name");
		String defaultVal = paramNode.attributeValue("defaultValue");
		getParameters().put(attrName, defaultVal);
       }
       
       return doc;
   }
 
Example 17
Source File: XmlMapperTest.java    From vjtools with Apache License 2.0 5 votes vote down vote up
/**
 * 使用Dom4j验证Jaxb所生成XML的正确性.
 */
private static void assertXmlByDom4j(String xml) {
	Document doc = null;
	try {
		doc = DocumentHelper.parseText(xml);
	} catch (DocumentException e) {
		fail(e.getMessage());
	}
	Element user = doc.getRootElement();
	assertThat(user.attribute("id").getValue()).isEqualTo("1");

	Element interests = (Element) doc.selectSingleNode("//interests");
	assertThat(interests.elements()).hasSize(2);
	assertThat(((Element) interests.elements().get(0)).getText()).isEqualTo("movie");
}
 
Example 18
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Processes the given input file.
 * 
 * @param summaryDoc The document object to add data to
 * @param inputFile  The input file
 */
private void processInputFile(Document summaryDoc, File inputFile) throws IOException
{
	try
	{
    	// First we check whether it is an XML file
		SAXReader reader  = new SAXReader();
        Document  testDoc = reader.read(new InputSource(new FileReader(inputFile)));

    	// Then we check whether it is one that we're interested in
        if (testDoc.selectSingleNode("/testsuite") == null)
        {
        	return;
        }

        // Ok, it is, so lets extract the data that we want:
        Element generalElement   = (Element)summaryDoc.selectSingleNode("//general");
        int     totalNumTests    = 0;
        int     totalNumErrors   = 0;
        int     totalNumFailures = 0;

        if (generalElement == null)
        {
        	generalElement = summaryDoc.getRootElement().addElement("general");

        	// General run info (we only need this once)
            generalElement.addAttribute("ddlUtilsVersion",
                                        _version);
        	generalElement.addAttribute("date",
                                        getAttrValue(testDoc, "//property[@name='TODAY']", "value"));
        	generalElement.addAttribute("lang",
                                        getAttrValue(testDoc, "//property[@name='env.LANG']", "value"));
        	generalElement.addAttribute("jre",
                                        getAttrValue(testDoc, "//property[@name='java.runtime.name']", "value") + " " +
                                        getAttrValue(testDoc, "//property[@name='java.runtime.version']", "value") + " (" +
                                        getAttrValue(testDoc, "//property[@name='java.vendor']", "value") + ")");
        	generalElement.addAttribute("os",
                                        getAttrValue(testDoc, "//property[@name='os.name']", "value") + " " +
                                        getAttrValue(testDoc, "//property[@name='os.version']", "value") + ", arch " +
                                        getAttrValue(testDoc, "//property[@name='os.arch']", "value"));
        	addTargetDatabaseInfo(generalElement,
                                  getAttrValue(testDoc, "//property[@name='jdbc.properties.file']", "value"));
        }
        else
        {
            totalNumTests    = Integer.parseInt(generalElement.attributeValue("tests"));
            totalNumErrors   = Integer.parseInt(generalElement.attributeValue("errors"));
            totalNumFailures = Integer.parseInt(generalElement.attributeValue("failures"));
        }

        int numTests    = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "tests"));
        int numErrors   = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "errors"));
        int numFailures = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "failures"));

        totalNumTests    += numTests;
        totalNumErrors   += numErrors;
        totalNumFailures += numFailures;

        generalElement.addAttribute("tests",    String.valueOf(totalNumTests));
        generalElement.addAttribute("errors",   String.valueOf(totalNumErrors));
        generalElement.addAttribute("failures", String.valueOf(totalNumFailures));

        if ((numErrors > 0) || (numFailures > 0))
        {
            Element testSuiteNode = (Element)testDoc.selectSingleNode("/testsuite");
            String  testSuiteName = testSuiteNode.attributeValue("name");

            // since tests have failed, we add it to the summary
            for (Iterator it = testSuiteNode.selectNodes("testcase[failure or error]").iterator(); it.hasNext();)
            {
                Element failedTestElement = (Element)it.next();
                Element newTestElement    = summaryDoc.getRootElement().addElement("failedTest");

                // Test setup failure, so the test was not actually run ?
                if (!failedTestElement.attributeValue("classname").startsWith("junit.framework.TestSuite"))
                {
                    newTestElement.addAttribute("name", failedTestElement.attributeValue("classname") + "#" + failedTestElement.attributeValue("name"));
                }
                newTestElement.addAttribute("testsuite", testSuiteName);
            }
        }
	}
	catch (DocumentException ex)
	{
		// No, apparently it's not an XML document, so we ignore it
	}
}
 
Example 19
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Processes the given input file.
 * 
 * @param summaryDoc The document object to add data to
 * @param inputFile  The input file
 */
private void processInputFile(Document summaryDoc, File inputFile) throws IOException
{
	try
	{
    	// First we check whether it is an XML file
		SAXReader reader  = new SAXReader();
        Document  testDoc = reader.read(new InputSource(new FileReader(inputFile)));

    	// Then we check whether it is one that we're interested in
        if (testDoc.selectSingleNode("/testsuite") == null)
        {
        	return;
        }

        // Ok, it is, so lets extract the data that we want:
        Element generalElement   = (Element)summaryDoc.selectSingleNode("//general");
        int     totalNumTests    = 0;
        int     totalNumErrors   = 0;
        int     totalNumFailures = 0;

        if (generalElement == null)
        {
        	generalElement = summaryDoc.getRootElement().addElement("general");

        	// General run info (we only need this once)
            generalElement.addAttribute("ddlUtilsVersion",
                                        _version);
        	generalElement.addAttribute("date",
                                        getAttrValue(testDoc, "//property[@name='TODAY']", "value"));
        	generalElement.addAttribute("lang",
                                        getAttrValue(testDoc, "//property[@name='env.LANG']", "value"));
        	generalElement.addAttribute("jre",
                                        getAttrValue(testDoc, "//property[@name='java.runtime.name']", "value") + " " +
                                        getAttrValue(testDoc, "//property[@name='java.runtime.version']", "value") + " (" +
                                        getAttrValue(testDoc, "//property[@name='java.vendor']", "value") + ")");
        	generalElement.addAttribute("os",
                                        getAttrValue(testDoc, "//property[@name='os.name']", "value") + " " +
                                        getAttrValue(testDoc, "//property[@name='os.version']", "value") + ", arch " +
                                        getAttrValue(testDoc, "//property[@name='os.arch']", "value"));
        	addTargetDatabaseInfo(generalElement,
                                  getAttrValue(testDoc, "//property[@name='jdbc.properties.file']", "value"));
        }
        else
        {
            totalNumTests    = Integer.parseInt(generalElement.attributeValue("tests"));
            totalNumErrors   = Integer.parseInt(generalElement.attributeValue("errors"));
            totalNumFailures = Integer.parseInt(generalElement.attributeValue("failures"));
        }

        int numTests    = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "tests"));
        int numErrors   = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "errors"));
        int numFailures = Integer.parseInt(getAttrValue(testDoc, "/testsuite", "failures"));

        totalNumTests    += numTests;
        totalNumErrors   += numErrors;
        totalNumFailures += numFailures;

        generalElement.addAttribute("tests",    String.valueOf(totalNumTests));
        generalElement.addAttribute("errors",   String.valueOf(totalNumErrors));
        generalElement.addAttribute("failures", String.valueOf(totalNumFailures));

        if ((numErrors > 0) || (numFailures > 0))
        {
            Element testSuiteNode = (Element)testDoc.selectSingleNode("/testsuite");
            String  testSuiteName = testSuiteNode.attributeValue("name");

            // since tests have failed, we add it to the summary
            for (Iterator it = testSuiteNode.selectNodes("testcase[failure or error]").iterator(); it.hasNext();)
            {
                Element failedTestElement = (Element)it.next();
                Element newTestElement    = summaryDoc.getRootElement().addElement("failedTest");

                // Test setup failure, so the test was not actually run ?
                if (!failedTestElement.attributeValue("classname").startsWith("junit.framework.TestSuite"))
                {
                    newTestElement.addAttribute("name", failedTestElement.attributeValue("classname") + "#" + failedTestElement.attributeValue("name"));
                }
                newTestElement.addAttribute("testsuite", testSuiteName);
            }
        }
	}
	catch (DocumentException ex)
	{
		// No, apparently it's not an XML document, so we ignore it
	}
}
 
Example 20
Source File: AssessmentContext.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Method setUp.
 * 
 * @param assessInstance
 */
public void setUp(AssessmentInstance assessInstance) {
    this.assessInstance = assessInstance;
    init();

    Document el_questestinterop = assessInstance.getResolver().getQTIDocument();
    el_assessment = (Element) el_questestinterop.selectSingleNode("questestinterop/assessment");

    ident = el_assessment.attributeValue("ident");
    title = el_assessment.attributeValue("title");
    Element dur = (Element) el_assessment.selectSingleNode("duration");

    if (dur == null) {
        durationLimit = -1; // no limit
    } else {
        String sdur = dur.getText();
        durationLimit = QTIHelper.parseISODuration(sdur);
        if (durationLimit == 0)
            durationLimit = -1; // Assesst Designer fix
    }

    // get objectives
    Element el_objectives = (Element) el_assessment.selectSingleNode("objectives");
    if (el_objectives != null)
        objectives = new Objectives(el_objectives);

    // set feedback, hint, and solutions switches
    // <!ENTITY % I_FeedbackSwitch " feedbackswitch (Yes | No ) 'Yes'">
    // <!ENTITY % I_HintSwitch " hintswitch (Yes | No ) 'Yes'">
    // <!ENTITY % I_SolutionSwitch " solutionswitch (Yes | No ) 'Yes'">

    // <!ELEMENT assessment (qticomment? , duration? , qtimetadata* ,
    // objectives* , assessmentcontrol* , rubric* , presentation_material? ,
    // outcomes_processing* , assessproc_extension? , assessfeedback* ,
    // selection_ordering? , reference? , (sectionref | section)+)>
    // <!ELEMENT assessmentcontrol (qticomment?)>
    Element el_control = (Element) el_assessment.selectSingleNode("assessmentcontrol");
    if (el_control != null) {
        String feedbackswitch = el_control.attributeValue("feedbackswitch");
        String hintswitch = el_control.attributeValue("hintswitch");
        String solutionswitch = el_control.attributeValue("solutionswitch");
        boolean feedback = (feedbackswitch == null) ? true : feedbackswitch.equals("Yes");
        boolean hints = (hintswitch == null) ? true : hintswitch.equals("Yes");
        boolean solutions = (solutionswitch == null) ? true : solutionswitch.equals("Yes");
        switches = new Switches(feedback, hints, solutions);
    }

    // scoring model and outcomes processing
    Element el_outpro = (Element) el_assessment.selectSingleNode("outcomes_processing");
    if (el_outpro != null) {
        // get the scoring model: we need it later for calculating the score
        // <!ENTITY % I_ScoreModel " scoremodel CDATA #IMPLIED">
        scoremodel = el_outpro.attributeValue("scoremodel");
        // may be null -> then assume SumOfScores

        // set the cutvalue if given (only variable score)
        cutvalue = QTIHelper.getFloatAttribute(el_outpro, "outcomes/decvar[@varname='SCORE']", "cutvalue");
        List<?> el_oft = el_outpro.selectNodes("outcomes_feedback_test");
        if (el_oft.size() != 0) {
            feedbacktesting = true;
        }
    }

    initSections(el_assessment, switches);
    init();
}