public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static Element |
addChild(Node parent,
String name)
Add a new child node to a parent node
The new child node will inherit the parent's namespace
|
static Element |
addChildBefore(Node parent,
Node child,
String name)
Add a new child node to a parent node before a child node
The new child node will inherit the parent's namespace
If the child node is null, the new child node will be added at the end of the list of children
|
static char |
convertBraille(char braille)
Convert a character from braille to lowercase text
Braille control characters are not changed
For characters with more than one text representation,
the most common one is chosen
e.g.
|
static char |
convertBrailleNumeric(char braille)
Convert a numeric character from braille to lowercase text
|
static Document |
convertToDocument(String xml)
Convert an XML string to a Document node
|
static Document |
convertToDocument(net.sf.saxon.s9api.XdmNode node)
Convert an XdmNode to a Document node
TODO this produces unwanted white space (it is converted with indent="true")
|
static net.sf.saxon.s9api.XdmNode |
convertToXdmNode(Document document,
net.sf.saxon.s9api.Processor processor,
boolean useFile)
Convert a Document node to an XdmNode
|
static String |
convertXmlEndtagsToHtmlEndtags(String xml)
Converts XML end tags to a HTML end tags
Each "/>" is replaced by ">" for the correct tag
|
static Node |
getChild(Node node,
String name)
Get the first child in the same namespace with a given name
|
static net.sf.saxon.s9api.XdmNode |
getChildNode(net.sf.saxon.s9api.XdmNode node,
net.sf.saxon.s9api.QName childName)
Get the first child node
|
static Node |
getFirstChildWithAttribute(Node node,
String name,
String attributeName,
String attributeValue)
Get the first child in the same namespace with a given name and a given attribute value
|
static Node |
getNextSiblingWithAttribute(Node node,
String name,
String attributeName,
String attributeValue)
Get the first sibling in the same namespace with a given name and a given attribute value
|
static String |
getValue(net.sf.saxon.s9api.XdmNode node,
net.sf.saxon.s9api.QName childName)
Get the string value of a child node
|
static boolean |
isBraille(char c)
Determine whether a unicode character is in the braille range
|
static boolean |
isBrailleDecimalSeparator(char braille)
Determine whether a braille character is a decimal separator
|
static boolean |
isBrailleDigit(char braille)
Determine whether a braille character is a digit
|
static boolean |
isBrailleMinus(char braille)
Determine whether a character is the minus sign
|
static boolean |
isBrailleMoneyZeros(char braille)
Determine whether a braille character can be used as a shorthand for 00 at the end of a price
E.g.
|
static boolean |
isDecimalSeparator(char c)
Determine whether a character is a decimal separator
|
static boolean |
isDigit(char c)
Determine whether a character is a digit
|
static boolean |
isMoneyZeros(char c)
Determine whether a character can be used as a shorthand for 00 at the end of a price
E.g.
|
static void |
removeNodes(Set<Node> nodes)
Remove nodes
|
static Node |
renameNode(Node node,
String newNodeName)
Rename a node and maintain the namespace
|
static String |
toString(Document document,
net.sf.saxon.s9api.DocumentBuilder documentBuilder)
Convert a Document node to an XML string
|
static String |
toString(net.sf.saxon.s9api.XdmNode node)
Convert an XdmNode to an XML string
|
public static Document convertToDocument(net.sf.saxon.s9api.XdmNode node) throws ParserConfigurationException, SAXException, IOException, net.sf.saxon.s9api.SaxonApiException
node - XdmNodeParserConfigurationException - thrown on parse exceptionsSAXException - thrown on a SAX exceptionIOException - thrown on an IO exceptionnet.sf.saxon.s9api.SaxonApiException - thrown on a Saxon API exceptionpublic static net.sf.saxon.s9api.XdmNode convertToXdmNode(Document document, net.sf.saxon.s9api.Processor processor, boolean useFile) throws IOException, net.sf.saxon.s9api.SaxonApiException
document - Document nodeprocessor - ProcessoruseFile - if true, the resulting XdmNode will be saved in a temporary file so that it has an URIIOException - thrown on an IO exceptionnet.sf.saxon.s9api.SaxonApiException - thrown on a Saxon API exceptionpublic static String toString(net.sf.saxon.s9api.XdmNode node) throws net.sf.saxon.s9api.SaxonApiException
node - XdmNodenet.sf.saxon.s9api.SaxonApiException - thrown on a Saxon API exceptionpublic static String toString(Document document, net.sf.saxon.s9api.DocumentBuilder documentBuilder) throws net.sf.saxon.s9api.SaxonApiException
document - Document nodedocumentBuilder - document buildernet.sf.saxon.s9api.SaxonApiException - thrown on a Saxon API exceptionpublic static Document convertToDocument(String xml) throws ParserConfigurationException, SAXException, IOException
xml - XML stringParserConfigurationException - thrown on parse exceptionsSAXException - thrown on a SAX exceptionIOException - thrown on an IO exceptionpublic static Node getChild(Node node, String name)
node - nodename - child node namepublic static Node getFirstChildWithAttribute(Node node, String name, String attributeName, String attributeValue)
node - nodename - child node nameattributeName - attribute nameattributeValue - attribute valuepublic static Node getNextSiblingWithAttribute(Node node, String name, String attributeName, String attributeValue)
node - nodename - sibling node nameattributeName - attribute nameattributeValue - attribute valuepublic static Element addChild(Node parent, String name)
parent - parent nodename - name of the child nodepublic static Element addChildBefore(Node parent, Node child, String name)
parent - parent nodechild - child node, can be nullname - name of the child nodepublic static Node renameNode(Node node, String newNodeName)
node - the node that will get a new node namenewNodeName - the new node namepublic static void removeNodes(Set<Node> nodes)
nodes - the nodes that must be removedpublic static net.sf.saxon.s9api.XdmNode getChildNode(net.sf.saxon.s9api.XdmNode node,
net.sf.saxon.s9api.QName childName)
node - XdmNodechildName - child namepublic static String getValue(net.sf.saxon.s9api.XdmNode node, net.sf.saxon.s9api.QName childName)
node - XdmNodechildName - child namepublic static String convertXmlEndtagsToHtmlEndtags(String xml)
xml - XML stringpublic static boolean isBraille(char c)
c - unicode characterpublic static char convertBraille(char braille)
braille - Braille characterpublic static boolean isBrailleDigit(char braille)
braille - braille characterpublic static boolean isDigit(char c)
c - characterpublic static char convertBrailleNumeric(char braille)
braille - Braille characterpublic static boolean isBrailleMinus(char braille)
braille - braille characterpublic static boolean isBrailleDecimalSeparator(char braille)
braille - braille characterpublic static boolean isDecimalSeparator(char c)
c - characterpublic static boolean isBrailleMoneyZeros(char braille)
braille - braille characterpublic static boolean isMoneyZeros(char c)
c - characterCopyright © 2010–2024 The DAISY Consortium. All rights reserved.