Class AuthoringXml
- java.lang.Object
-
- org.sakaiproject.tool.assessment.qti.helper.AuthoringXml
-
public class AuthoringXml extends Object
Utility to load XML templates from Sprint context or local file system.
Copyright: Copyright (c) 2005 Sakai
- Version:
- $Id$
- Author:
- Ed Smiley esmiley@stanford.edu
-
-
Field Summary
Fields Modifier and Type Field Description static StringASSESSMENTstatic StringITEM_AUDIOstatic StringITEM_CALCQstatic StringITEM_EMIstatic StringITEM_ESSAYstatic StringITEM_FIBstatic StringITEM_FILEstatic StringITEM_FINstatic StringITEM_IMAGMQstatic StringITEM_MATCHstatic StringITEM_MATCHINGstatic StringITEM_MCMCstatic StringITEM_MCMC_SSstatic StringITEM_MCSCstatic StringITEM_MXSURVEYstatic StringITEM_SURVEYstatic StringITEM_TFstatic StringSECTIONstatic StringSETTINGS_FILEstatic StringSURVEY_10static StringSURVEY_5static StringSURVEY_AGREEstatic StringSURVEY_AVERAGEstatic StringSURVEY_EXCELLENTstatic StringSURVEY_PATHstatic StringSURVEY_STRONGLYstatic StringSURVEY_UNDECIDEDstatic StringSURVEY_YESstatic StringTEMPLATE_PATHMapvalidTemplates
-
Constructor Summary
Constructors Constructor Description AuthoringXml(int qtiVersion)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentaddAttribute(Document document, String elementXpath, String attributeName)Based on method in XmlStringBufferDocumentaddElement(Document document, String parentXpath, Element element)Based on method in XmlStringBufferStringgetQtiPath()intgetQtiVersion()StringgetTemplateAsString(InputStream templateStream)get a template as a string from its input streamInputStreamgetTemplateInputStream(String templateName)get template as stream using spring's ClassPathResourcebooleanisAssessment(String documentType)booleanisItem(String documentType)booleanisSection(String documentType)booleanisSurveyFragment(String documentType)static DocumentreadDocumentFromString(String in)Read a DOM Document from xml in a string.DocumentreadXMLDocument(InputStream inputStream)read in XML document from input streamListselectNodes(Document document, String xpath)Based on method in XmlStringBuffervoidsetQtiPath(String qtiPath)voidsetQtiVersion(int qtiVersion)Documentupdate(Document document, String xpath, String value)perform Update on this object Based on method originally in XmlStringBufferDocumentupdate(Document document, String xpath, Element element)Based on method in XmlStringBufferbooleanvalid(String s)test that a String is a valid template key
-
-
-
Field Detail
-
SETTINGS_FILE
public static final String SETTINGS_FILE
- See Also:
- Constant Field Values
-
TEMPLATE_PATH
public static final String TEMPLATE_PATH
- See Also:
- Constant Field Values
-
SURVEY_PATH
public static final String SURVEY_PATH
- See Also:
- Constant Field Values
-
ASSESSMENT
public static final String ASSESSMENT
- See Also:
- Constant Field Values
-
SECTION
public static final String SECTION
- See Also:
- Constant Field Values
-
ITEM_AUDIO
public static final String ITEM_AUDIO
- See Also:
- Constant Field Values
-
ITEM_ESSAY
public static final String ITEM_ESSAY
- See Also:
- Constant Field Values
-
ITEM_FIB
public static final String ITEM_FIB
- See Also:
- Constant Field Values
-
ITEM_FIN
public static final String ITEM_FIN
- See Also:
- Constant Field Values
-
ITEM_FILE
public static final String ITEM_FILE
- See Also:
- Constant Field Values
-
ITEM_MATCH
public static final String ITEM_MATCH
- See Also:
- Constant Field Values
-
ITEM_MCMC
public static final String ITEM_MCMC
- See Also:
- Constant Field Values
-
ITEM_MCMC_SS
public static final String ITEM_MCMC_SS
- See Also:
- Constant Field Values
-
ITEM_MCSC
public static final String ITEM_MCSC
- See Also:
- Constant Field Values
-
ITEM_SURVEY
public static final String ITEM_SURVEY
- See Also:
- Constant Field Values
-
ITEM_TF
public static final String ITEM_TF
- See Also:
- Constant Field Values
-
ITEM_MATCHING
public static final String ITEM_MATCHING
- See Also:
- Constant Field Values
-
ITEM_MXSURVEY
public static final String ITEM_MXSURVEY
- See Also:
- Constant Field Values
-
ITEM_CALCQ
public static final String ITEM_CALCQ
- See Also:
- Constant Field Values
-
ITEM_IMAGMQ
public static final String ITEM_IMAGMQ
- See Also:
- Constant Field Values
-
ITEM_EMI
public static final String ITEM_EMI
- See Also:
- Constant Field Values
-
SURVEY_10
public static final String SURVEY_10
- See Also:
- Constant Field Values
-
SURVEY_5
public static final String SURVEY_5
- See Also:
- Constant Field Values
-
SURVEY_AGREE
public static final String SURVEY_AGREE
- See Also:
- Constant Field Values
-
SURVEY_AVERAGE
public static final String SURVEY_AVERAGE
- See Also:
- Constant Field Values
-
SURVEY_EXCELLENT
public static final String SURVEY_EXCELLENT
- See Also:
- Constant Field Values
-
SURVEY_STRONGLY
public static final String SURVEY_STRONGLY
- See Also:
- Constant Field Values
-
SURVEY_UNDECIDED
public static final String SURVEY_UNDECIDED
- See Also:
- Constant Field Values
-
SURVEY_YES
public static final String SURVEY_YES
- See Also:
- Constant Field Values
-
validTemplates
public Map validTemplates
-
-
Method Detail
-
valid
public boolean valid(String s)
test that a String is a valid template key- Parameters:
s- a key- Returns:
- true if it is a valid key
-
getTemplateInputStream
public InputStream getTemplateInputStream(String templateName)
get template as stream using spring's ClassPathResource- Parameters:
templateName-context-- Returns:
-
getTemplateAsString
public String getTemplateAsString(InputStream templateStream)
get a template as a string from its input stream- Parameters:
templateName-- Returns:
- the xml string
-
isAssessment
public boolean isAssessment(String documentType)
-
isSection
public boolean isSection(String documentType)
-
isItem
public boolean isItem(String documentType)
-
isSurveyFragment
public boolean isSurveyFragment(String documentType)
-
update
public Document update(Document document, String xpath, Element element)
Based on method in XmlStringBuffer- Parameters:
document- Documentxpath-element-- Returns:
- modified Document
-
update
public Document update(Document document, String xpath, String value) throws DOMException, Exception
perform Update on this object Based on method originally in XmlStringBuffer- Parameters:
document- Documentxpath- :- xpath andvalue- :- Value of xpath- Returns:
- modified Document
- Throws:
DOMException- DOCUMENTATION PENDINGException- DOCUMENTATION PENDING
-
addElement
public Document addElement(Document document, String parentXpath, Element element)
Based on method in XmlStringBuffer- Parameters:
document- DocumentparentXpath-element-- Returns:
- modified Document
-
addAttribute
public Document addAttribute(Document document, String elementXpath, String attributeName)
Based on method in XmlStringBuffer- Parameters:
document- DocumentelementXpath-attributeName-- Returns:
- modified Document
-
selectNodes
public final List selectNodes(Document document, String xpath)
Based on method in XmlStringBuffer- Returns:
- a List of Nodes
-
readXMLDocument
public Document readXMLDocument(InputStream inputStream)
read in XML document from input stream- Parameters:
inputStream- source for XML document- Returns:
- the Document
-
readDocumentFromString
public static Document readDocumentFromString(String in)
Read a DOM Document from xml in a string.- Parameters:
in- The string containing the XML- Returns:
- A new DOM Document with the xml contents.
-
getQtiVersion
public int getQtiVersion()
-
setQtiVersion
public void setQtiVersion(int qtiVersion)
-
getQtiPath
public String getQtiPath()
-
setQtiPath
public void setQtiPath(String qtiPath)
-
-