
com.bytekast.sweettalk.util.NamespaceUtil.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sweet-talk Show documentation
Show all versions of sweet-talk Show documentation
A Sensible NetSuite SuiteTalk API wrapper
The newest version!
package com.bytekast.sweettalk.util
import groovy.transform.CompileStatic
import groovy.xml.XmlUtil
import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.stream.StreamSource
@Singleton
@CompileStatic
class NamespaceUtil {
private applyXslt(String xslt, String xml) {
def transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(xslt)))
def writer = new StringWriter()
transformer.transform(new StreamSource(new StringReader(xml.trim())), new StreamResult(writer))
XmlUtil.serialize(writer.toString())
}
String removeXmlNamespaces(String xml) {
applyXslt(this.class.getResource('/remove_namespaces.xslt').text?.trim(), xml)
}
String normalizeXmlNamespaces(String xml) {
applyXslt(this.class.getResource('/normalize_namespaces.xslt').text?.trim(), xml)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy