Class XmlUtil
- java.lang.Object
-
- org.sakaiproject.tool.assessment.qti.util.XmlUtil
-
public final class XmlUtil extends Object
Copyright: Copyright (c) 2005
Organization: Sakai Project
- Version:
- $Id$
- Author:
- palcasi mods:, Rachel Gollub rgollub@stanford.edu, Ed Smiley esmiley@stanford.edu
-
-
Constructor Summary
Constructors Constructor Description XmlUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringconvertoLTGT(String value)static StringconvertStrforCDATA(String myString)Deprecated.use convertToSingleCDATAstatic StringconvertToSingleCDATA(String text)static DocumentcreateDocument()Create document objectstatic DocumentcreateDocument(String xmlString)Create document object from XML stringstatic TransformercreateTransformer(DOMSource source)Create a transformer from a stylesheetstatic TransformercreateTransformer(Document stylesheet)Create a transformer from a stylesheetstatic DOMSourcegetDocumentSource(javax.servlet.ServletContext context, String path)static StringgetDOMString(Node node)Get a textual representation of a Node.static StringprocessFormattedText(String value)static DocumentreadDocument(String path)Read document from within spring context pathstatic DocumentreadDocument(String path, boolean trim)This more forgiving version skips blank lines if trim = true Otherwise it does a direct parse of the file.static DocumentreadDocument(javax.servlet.ServletContext context, String path)Read document from ServletContext/context pathstatic DocumenttransformDocument(Document document, Transformer transformer)static DocumenttransformDocument(Document document, Document stylesheet)Transform one document into anotherstatic voidtransformNode(Node source, Node result, Transformer transformer)
-
-
-
Method Detail
-
createDocument
public static Document createDocument()
Create document object- Returns:
- Document
-
createDocument
public static Document createDocument(String xmlString)
Create document object from XML string- Returns:
- Document
-
readDocument
public static Document readDocument(javax.servlet.ServletContext context, String path)
Read document from ServletContext/context path- Parameters:
context- ServletContextpath- path- Returns:
- Document
-
readDocument
public static Document readDocument(String path)
Read document from within spring context path- Parameters:
path- path- Returns:
- Document
-
getDocumentSource
public static DOMSource getDocumentSource(javax.servlet.ServletContext context, String path)
-
readDocument
public static Document readDocument(String path, boolean trim) throws ParserConfigurationException, SAXException, IOException
This more forgiving version skips blank lines if trim = true Otherwise it does a direct parse of the file.- Parameters:
path- file pathtrim- trim blank lines true/false- Returns:
- Throws:
ParserConfigurationExceptionSAXExceptionIOException
-
createTransformer
public static Transformer createTransformer(Document stylesheet)
Create a transformer from a stylesheet- Parameters:
stylesheet- Document- Returns:
- the Transformer
-
createTransformer
public static Transformer createTransformer(DOMSource source)
Create a transformer from a stylesheet- Parameters:
source- DOMSource- Returns:
- the Transformer
-
transformDocument
public static Document transformDocument(Document document, Document stylesheet)
Transform one document into another- Parameters:
document- source Documentstylesheet- XSLT Document- Returns:
- transformed Document
-
transformDocument
public static Document transformDocument(Document document, Transformer transformer)
-
transformNode
public static void transformNode(Node source, Node result, Transformer transformer)
-
getDOMString
public static String getDOMString(Node node)
Get a textual representation of a Node.- Parameters:
node- The Node- Returns:
- the document in a text string
-
convertStrforCDATA
@Deprecated public static String convertStrforCDATA(String myString)
Deprecated.use convertToSingleCDATA- Parameters:
myString-- Returns:
-
-