Subject:Mapping Trouble Author:rajat nair Date:19 Dec 2007 12:43 PM
Hi,
I m trying to map xml to xml using the mapping feature in the stylus studio enterprise suite and is unable to map a case like the following
<RequestDetail>
<ItemNumber source="me">12345</ItemNumber>
<ItemNumber source="we">abcd</ItemNumber>
<ItemNumber source="see">blahblah</ItemNumber>
</RequestDetail>
In the above xml snippet i want the first ItemNumber source "me" to get mapped to <firsthere> tag in the target xml and the second ItemNumber source "we" to get mapped to <secondhere> tag in the target xml, but when i add the source xml to the mapping utility, it just shows
ItemNumber
-- source
How do i resolve this, any help would be appreciated.
Subject:Mapping Trouble Author:Minollo I. Date:19 Dec 2007 01:45 PM
If I drag&drop a source document with the structure you are describing, I see:
- RequestDetail
- ItemNumber
- source
...which is what I would expect. the panel shows the *structure* of the document, not its data. To do something like what you are describing, you need to create some mapping to a specific structure; possibly with "if" conditions if such mapping is controlled by values rather than by structure.
If you provide a few more details, we can try to get you started; what is the structure, the schema of the result you are trying to get? What is the logic you follow to map information in the source to that structure? Is it based on position of the elements in the source document? Or on values of the attributes?
Subject:Mapping Trouble Author:rajat nair Date:19 Dec 2007 03:14 PM
I have emailed the source document to stylus-field-report@progress.com
yes the mapping has to be attribute value based.The source doucment has to be mapped out into a OAG target document.
>If I drag&drop a source
>document with the structure
>you are describing, I see:
> - RequestDetail
> - ItemNumber
> - source
>
>...which is what I would
>expect. the panel shows the
>*structure* of the document,
>not its data. To do something
>like what you are describing,
>you need to create some
>mapping to a specific
>structure; possibly with "if"
>conditions if such mapping is
>controlled by values rather
>than by structure.
>
>If you provide a few more
>details, we can try to get you
>started; what is the
>structure, the schema of the
>result you are trying to get?
>What is the logic you follow
>to map information in the
>source to that structure? Is
>it based on position of the
>elements in the source
>document? Or on values of the
>attributes?
Subject:Mapping Trouble Author:Minollo I. Date:19 Dec 2007 03:58 PM
I'm not going into the details of your whole mapping goals, but value based mappings can be usually accomplished creating chains of if conditions in mapper (and XQuery). See this XQuery, for example, in mapper; it should give you an idea about how it works.
<root>
{
for $RequestDetail in doc('file:///c:/Tp_request.xml')/TradePowerRequest/RequestDetail
return
<items>
{
if( $RequestDetail/ItemNumber/@source = "UI" ) then
<item1>
{$RequestDetail/ItemDescription/text()}
</item1>
else
()
}
{
if( $RequestDetail/ItemNumber/@source = "MP" ) then
<item2>
{$RequestDetail/ItemDescription/text()}
</item2>
else
<item3>
{$RequestDetail/ItemDescription/text()}
</item3>
}
</items>
}
</root>