Child pages
  • KB89434355: Automation Engine - How to migrate from XPath SmartNames to XPath Query SmartNames and XMP XPath SmartNames to XMP XPath Query SmartNames
Skip to end of metadata
Go to start of metadata

 

Description

In Automation Engine 14.0, two new SmartName types were introduced namely XPath Query SmartName and XMP XPath Query SmartName. These new SmartName types replace the existing XPath SmartName and XMP XPath SmartName type. XPath or XMP XPath SmartNames which were defined in versions older than Automation Engine 14.0 are untouched after the upgrade to Automation Engine 14.0 and will continue to work, but you will no longer be able to create new SmartNames of type XPath or XMP XPath. You are encouraged to migrate to the new XPath Query type and XMP XPath Query type.

New SmartName types were introduced because the existing ones were no longer adequate for some new use cases in the area of business system integration:

  • Defining an XPath SmartName which returns an XML Element was not possible. The existing XPath type returned the concatenation of all child text nodes instead.
  • Defining an XPath SmartName using namespace prefixes was not possible. This was expected to work by advanced users.

Procedure

Modify XPath Expressions selecting text

The existing XPath and XMP XPath SmartName type returned the XSLT-compatible text representation of the selected nodes, i.e. all text node values are concatenated, while the XPath and XMP XPath Query SmartName type returns the XML representation of the selected nodes. This is considered more useful in XML based workflows.

Example
<doc>
   <par>
     <elem>first</elem>
     <elem>second</elem>
   </par>
   <par>
     <elem>third</elem>
   </par>
</doc>
XPath SmartName




XPath Query SmartName
ExpressionResultExpressionResult
/doc/par[1]


first
second

/doc/par[1]
<par>
  <elem>first</elem>
  <elem>second</elem>
<par>
string(/doc/par[1])
first
second

/doc/par[2]third/doc/par[2]
<par>
  <elem>third</elem>
<par>
/doc/par[2]/text()third
/doc/par/elemfirst/doc/par/elem<elem>first</elem><elem>second</elem><elem>third</elem>
string(/doc/par/elem)first
When the text value is wanted, you can explicitly ask for it, for example using the XPath expression "/doc/par[2]/elem/text()" or using "string(/doc/par[1])"

Modify XPath Expressions for XML Namespaces

XPath SmartNames whereby the XML input contains no XML Namespace declarations can be easily converted into an XPath Query SmartName. No changes need to be done to the XPath Expression.

XPath SmartNames whereby the XML input contains a default XML Namespace declaration (e.g a JDF file) with no prefix need to be adapted when converted into an XPath Query SmartName, i.e. an empty prefix need to be added in the XPath Expression as shown in the example below or use the local-name function.

Example XML with default namespace
<?xml version="1.0" encoding="UTF-8"?>
<JDF xmlns="http://www.CIP4.org/JDFSchema_1_1" Version="1.3">
	<Comment Name="Description">JobDescription</Comment>
	<Comment Name="Description2">MyCategory</Comment>
</JDF>
XPath SmartName



XPath Query SmartName
ExpressionResultExpressionResult
//JDF/Comment[@Name='Description2']
MyCategory
//:JDF/:Comment[@Name='Description2']/text()
MyCategory
/*[local-name() = 'JDF']/*[local-name() = 'Comment'][@Name = 'Description2']MyCategory/*[local-name() = 'JDF']/*[local-name() = 'Comment'][@Name = 'Description2']/text()MyCategory

XPath SmartNames whereby the XML input contains an explicit XML Namespace declaration, i.e. with a prefix, need to be adapted when converted into an XPath Query SmartName, i.e. the namespace prefix needs to be added in the XPath Expression as shown in the example below or use the local-name function.

Example XML Document
<?xml version="1.0" encoding="UTF-8"?>
<test:XPathTest test:Version="14.0" xmlns:test="http://www.test.com">
	<test:XPathElement test:Index="1">Text1</test:XPathElement>
	<test:XPathElement test:Index="2">Text2</test:XPathElement>
	<test:XPathElement test:Index="3">Text3</test:XPathElement>
	<test:XPathElement test:Index="4">Text4</test:XPathElement>
	<test:Likes>999</test:Likes>
</test:XPathTest>
XPath SmartName



XPath Query SmartName
ExpressionResultExpressionResult
/XPathTest/Likes
999
/test:XPathTest/test:Likes/text()
999
/*[local-name() = 'XPathTest']/*[local-name() = 'Likes']999/*[local-name() = 'XPathTest']/*[local-name() = 'Likes']/text()999

XMP sections declare namespace prefixes and namespaces. Consequently, XMP XPath SmartNames need to be adapted when you want to convert them into an XMP XPath Query SmartName, i.e. the namespace prefixes need to be added to the XPath Expression or the local-name function needs to be used.

XMP Example
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/" rdf:about="">
         <egGr:nrpages>1</egGr:nrpages>
         <egGr:startlogpage>1</egGr:startlogpage>
         <egGr:units>mm</egGr:units>
         <egGr:vsize>82.77729797</egGr:vsize>
         <egGr:hsize>178.0466003</egGr:hsize>
         <egGr:margtop>0.</egGr:margtop>
         <egGr:margbot>0.</egGr:margbot>
         <egGr:margleft>.02580000088</egGr:margleft>
         <egGr:margright>0.</egGr:margright>
         <egGr:vshrink>1.</egGr:vshrink>
         <egGr:hshrink>1.</egGr:hshrink>
         <egGr:readerspread>False</egGr:readerspread>
         <egGr:colorprofloc>Untagged</egGr:colorprofloc>
         <egGr:colorprofname/>
         <egGr:colorprofdesc/>
         <egGr:screenreg>False</egGr:screenreg>
         <egGr:inks>
            <rdf:Seq>
               <rdf:li rdf:parseType="Resource">
                  <egInk:name>5625</egInk:name>
        ...
XMP XPath SmartName



XMP XPath Query SmartName
ExpressionResultExpressionResult
/xmpmeta/RDF/Description[1]/vsize
82.77729797
/x:xmpmeta/rdf:RDF/rdf:Description[1]/egGr:vsize/text()
82.77729797
/*[local-name()='xmpmeta']/*[local-name()='RDF']/*[local-name()='Description'][1]/*[local-name()='vsize']
82.77729797
/*[local-name()='xmpmeta']/*[local-name()='RDF']/*[local-name()='Description'][1]/*[local-name()='vsize']/text()
82.77729797
//vsize
82.77729797
//egGr:vsize/text()
82.77729797
Article information
Applies to

Automation Engine 14.0 and higher

Created23-May-14
Last revised 
AuthorFL
CW Number 
Contents