cancel
Showing results for 
Search instead for 
Did you mean: 

Xpath

Former Member
0 Kudos

Hi,

can u please expain the difference between X-Path and Context Objects.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Vijaya

i am giving you simple and short description of what is XAPTH and context object

Context: context are the pointers to the variable

XPATH used to exploer node in a structure in any hiererchical level

For example you have a xpath for a node like this for your identification (name)

<IDOC/BEGIN/COUNTRY/CITY/STREET/WING/BUILDINGNAME/HOUSENO/YOURNAME>

now suppose in your developement you have to use this TAG several times

then its very cumbersome task to write it again and again also it decreases readablity of the program.so to make it simple you can use context to this XPATH for your name TAG

context are nothing these are used just to replace XPATH

hope this may clarify you about XPATH and context in the simplest way

regards

sandeep

if helpful kindly reward points

Former Member
0 Kudos

Context objects are a simple alternative to XPath expressions for accessing the contents of a message.

It is used for condition based routing. You create a context object in IR and assign it to a interface in IR. You can use the same in ID in receiver agreement(condition) to check the value at run time... Based on the value you can decide the receiver at run time..

If XPATH is complex that it cannot be referred to easily in the design / config time, it is easier to encapsulate the path of the data in a Context Object and then use this Context Object to refer to the entire XPATH.

Please refer below link for example

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

/people/prasadbabu.nemalikanti3/blog/2006/09/20/receiver-determination-based-on-the-payload-of-input-dataextended-xpathcontext-object

XPATH is a Web standard for navigating in XML documents. XPATH location paths are used to extract information from the structure of an XML document, such as the author or the page number. This information is then used for XML indexing.

An XPATH location path comprises a base path and a value path.

• The base path describes a node set in the XML document.

• The value path describes the values that you want to determine from this node set.

Customise your 'XPATH' Expressions in Receiver Determination

/people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination

/people/shabarish.vijayakumar/blog/2005/08/03/xpath-to-show-the-path-multiple-receivers

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/92/af463c36a30319e10000000a114084/frameset.htm

/people/daniel.graversen/blog/2006/12/29/hack-using-xpath-in-xi-message-mappings

Illustration of Enhanced Receiver Determination - SP16

/people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16

Hack: Using XPATH in XI Message Mappings

/people/daniel.graversen/blog/2006/12/29/hack-using-xpath-in-xi-message-mappings

XPath in the adapter framework

The package javax.xml.xpath was introduced with Java 5 (1.5), thus it is not available in XI which runs Java 1.4.2. There are (at least) a couple of ways to use XPath in Java 1.4:

1. Use a third-party library that supports XPath, for instance Xalan-J from Apache.

2. Embed your XPath expression in an XSLT transformation, execute the transformation using classes from the javax.xml.tranform... packages (which are part 1.4) and extract the result.

1. Does not work. The XI has following restriction: Only one XML parser exist in the adapter framework. If I change the parser for my adapter the change will affect all adapters.

I gues the class loader for the adapter framework must be implemented in an other way. Each adapter should have its own class loader.

2. This could be a way. Currently I implemented the customer requirement with the SAP SAX parser.

xpath functions in xslt mapping

/people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping

Difference between context object and x-path:

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

/people/prasadbabu.nemalikanti3/blog/2006/09/20/receiver-determination-based-on-the-payload-of-input-dataextended-xpathcontext-object

Receiver Det- Xpath:

/people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination

/people/shabarish.vijayakumar/blog/2005/08/03/xpath-to-show-the-path-multiple-receivers

XPATH in Interfce Det:

/people/suraj.sr/blog/2006/01/05/multiple-inbound-interfaces-within-a-service

Former Member
0 Kudos

HI

XPATH:It’s a specification of XML family, using this we can address any node in XML document. We can define mappings using XSLT together with XPATH. XSLT implements XPATH expressions to select substructures of a XML documents. We can use XSLT tags <XSL:import>

<XSL:include>to include predefined templates for substructures

Context Objects: These are alternative to XPATH expressions for accessing the contents of a message.

Follow the below links for further information

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

Technical Context Objects :

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

A list of the Technical Context Objects names can be found here:

http://help.sap.com/saphelp_nw04/helpdata/en/6e/ff0bf75772457b863ef5d99bc92404/content.htm

Difference between context object and x-path:

regards

Former Member
0 Kudos

Hi,

1. x-path

It's just the path from the root to your field. (e.g /myMessage/myRow/myAddress/myField)

You see this x-path in the Receiver Determination (for instance) when you want to manage a condition for the receiver.

note: it's exaclty the same path than this one providen by the right click "Copy path" in the Graphical Mapping.

2. Context-Object is like an Alias (a pointer).

You can define it into IR (e.g myContext) with "Create a new Context-Object" and then always in IR, you can use it into your Interface Message (see the tab called "Context") in order to affect this alias to a specific field.

(e.g myContext <-> /myMessage/myRow/myAddress/myField)

And then,(for instance) in the Integration Directory, for the Receiver Determination you can define a condition (filter) DIRECTLY by using this Context name, WITHOUT to display the whole XML tree. By this way, you can simplify the configuration of your flow, because it's easier to use a Context name (e.g myContext) compare to deployed the structure tree in order to find your field (e.g /myMessage/myRow/myAddress/myField).

Moreover, as you associate the field to the Context only ONCE (in the IR, interface message), you decrease the posibility to do an error in the ID config, especially if fieldname are quasi-similar: addressName, adrName, addressSupplierName, AddressClientName.

Note: x-path and Context can also be used in BPM for a condition a branch (for instance).

Hope this help you to understand the advantage of "Context" compare to a simple "x-path".

Regards.

Mickael

former_member556603
Active Contributor
0 Kudos

Hi Vijaya,

Context objects are a simple alternative to XPath expressions for accessing the contents of a message.

It is used for condition based routing. You create a context object in IR and assign it to a interface in IR. You can use the same in ID in receiver agreement(condition) to check the value at run time... Based on the value you can decide the receiver at run time..

If XPATH is complex that it cannot be referred to easily in the design / config time, it is easier to encapsulate the path of the data in a Context Object and then use this Context Object to refer to the entire XPATH.

Get the details here:

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

Technical Context Objects :

http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm

A list of the Technical Context Objects names can be found here:

http://help.sap.com/saphelp_nw04/helpdata/en/6e/ff0bf75772457b863ef5d99bc92404/content.htm

Difference between context object and x-path:

Thanks,

Satya

Shabarish_Nair
Active Contributor
0 Kudos

<fA>

<fB>

<fC/>

</fB>

</fA>

if the above is your xml then the xpath for the node C is /fA/fB/fC

now the xpath /fA/fB/fC can be assigned to a variable say fieldC i.e

fieldC = /fA/fB/fC thus fieldC becomes the context object for the xpath /fA/fB/fC

Hope its clear.