XML Actions
Parse serialized XML.
Property | Value | Description |
|---|---|---|
xmlString* | text, expression, variable | a String, InputStream, or Reader containing serialized XML |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
# Parse the XML so we can retrieve the desired data parsedXML = parseXML(individualrecord['data'])
Returns a copy of the XML with the namespaces removed.
Property | Value | Description |
|---|---|---|
xml* | expression, variable | the input XML |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
# Remove all erroneous XML Name Spaces individualRecord['data']= stripXMLNamespaces(individualRecord['data'])
Convert Objects, Records, Arrays, etc. to XML.
Property | Value | Description |
|---|---|---|
object* | expression, variable | the Object, Record, Arrays, etc to convert |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
data = toXML(record)
Evaluate an XPath 1.0 expression against XML and return an XMLList containing the results.
Property | Value | Description |
|---|---|---|
expression* | text, expression, variable | the XPath 1.0 expression |
xml* | expression, variable | the XML |
namespaces | expression, variable | an Object or Record that maps namespace prefixes to URIs |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
requestID = xpath("ec2:requestID", data, varNamespaces)Transform XML using XSLT 1.0.
Property | Value | Description |
|---|---|---|
stylesheet* | text, expression, variable | Path the the XSLT stylesheet |
xml* | expression, variable | the input XML |
parameters | expression, variable | an Object or Record containing named stylesheet parameters |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
# --Sample Action Set Showing Output of DSML 1.0 (XSLT Version)--
#
# map the dsml namespace
dsml = new Namespace("http://www.dsml.org/DSML")
# get records from DT file
input = openDelimitedTextInput("demodata/sample.csv",
"LastName,FirstName,Title,Email,Work,Fax,Mobile,Description")
# convert to generic XML
inputXML = toXML(input)
log(inputXML)
# convert generic XML to DSML using stylesheet
varDSML = xslt("demodata/dsmloutput.xsl", inputXML)
log(varDSML)
saveToFile("/tmp/output.dsml", varDSML)
close(input)<dsml xmlns="http://www.dsml.org/DSML" xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<directory-entries>
<xsl:for-each select="//record">
<entry dn="{field[@name='@dn']/value}">
<xsl:if test="field[@name='objectClass' or
@name='objectclass']">
<objectclass>
<xsl:for-each select="field[@name='objectClass' or
@name='objectclass']/value">
<oc-value>
<xsl:value-of select="."/>
</oc-value>
</xsl:for-each>
</objectclass>
</xsl:if>
<xsl:for-each select="field[not(@name='objectClass' or
@name='objectclass' or @name='@dn')]">
<attr name="@name">
<xsl:for-each select="value">
<value>
<xsl:value-of select="."/>
</value>
</xsl:for-each>
</attr>
</xsl:for-each>
</entry>
</xsl:for-each>
</directory-entries>
</dsml>