[an error occurred while processing this directive]
> developer > web app development
FAQ-How do I map an unknown document type at runtime?
by exteNd Composer Product Team, eBusiness Integration Products, Novell
Date Created: 2001-02-23 09:14:00.000
  Introduction
introduction
FAQ: How do I map an unknown document type at runtime? 

Its hard to think of a particular case in a B2B scenario where you would define a service that accepts any type of XML document, but for testing purposes we have found it very useful to have a generic Service that accepts any document, and does some very simple processing. xCommerce has a special XML Template called {System} {ANY} designed to accept any XML document as Input or Output. So if you define the input for a Service or Component using {System} {ANY} the issue becomes how do you map its structure/content which you don't know and could be anything at runtime?

The answer is simpler than it appears but is limited in its mapping utility. To map this unknown Input document to another DOM like Output, simply reference each DOM's context as the Source and Target to the basic Map action. This allows you to map the entire document without reference to its details.

The vast majority of mapping specifications in a Map Action reference a document context combined with an XPath expression. The document context is usually just the name of a DOM like Input or Output (but can also be a Repeat alias) and the XPath expression is a hierarchical list of elements separated by the slash character. While it may not be obvious, Designer does allows you to use just the context all by itself. There are two ways to do this. The first uses a pure XPath expression and the second uses a pure ECMAScript expression.

Using XPath to reference the document object as the Source for a Map action, select the XPath radio button in the Map dialog, and pick Input as the XPath context. Then use the "current location" XPath specifier; the dot (.) for the XPath expression (look carefully as the dot all by itself is easy to overlook). Do likewise for the Target and you are done. If you don't yet have a sample document loaded into the Input DOM, Designer may display an error. Ignore this, load a sample and test your component/service.

   

Using ECMAScript in this case, select the Expression radio button for both the Source and Target to the Map action. Since Input and Output are reserved ECMAScript extensions/variables that refer to component DOMs you can simply type Input and Output (no quotes) as the respective expressions.