XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
james nuzzoSubject: XSLT Mapping XML to XML: Repeating Attribute Value Pairs to Flat structure
Author: james nuzzo
Date: 13 Dec 2006 10:55 AM
Have inbound XML with a Unbound Node META which as two elements:
Attribute_Name and Attribute_Value.

I wish to conditional map each row to specific Named node on target XML.
(i.e., Flatfile_Template, XST_Record_2_Canonical) with the corresponding Attribute_Value assigned.

Inbound XML.

<?xml version="1.0"?>
<INBND_META_DATA>
<Interface_MetaData>
<PrettyName>VCP-Gemini to SAP Modify Bonus Payment</PrettyName>
<RiceID>ICP-006</RiceID>
<TargetType>IDOC</TargetType>
<SourceType>FlatFIle</SourceType>
<Meta>
<Attribute_Name>XST_Record_2_Canonical</Attribute_Name>
<Attribute_Value>Some URI</Attribute_Value>
</Meta>
<Meta> <Attribute_Name>FlatFile_Template</Attribute_Name>
<Attribute_Value>No idea</Attribute_Value>
</Meta>
<Meta>
<Attribute_Name>XSLT_Canoical_2_SAP_Inbound_Adapter</Attribute_Name>
<Attribute_Value>Another URI</Attribute_Value>
</Meta>
<DIRECTION>IN</DIRECTION>
</Interface_MetaData>
</INBND_META_DATA>

Target XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="FF_META_DATA">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="MetaData">
<xs:complexType>
<xs:sequence>
<xs:element name="Flatfile_Template" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="XSLT_Record_2_Canonical" type="xs:short" nillable="true" minOccurs="0"/>
<xs:element name="XSLT_Canonical_2_SAP_Inbound_Adapter" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="PrettyName" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="IDoc" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="TX_Log_INTRFC_ID" type="xs:string" nillable="false"/>
<xs:element name="TX_Log_BTCH_ID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="RiceID" type="xs:string" nillable="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


My XSLT is like this:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<FF_META_DATA>
<MetaData>
<Flatfile_Template>
<xsl:if test="INBND_META_DATA/Interface_MetaData/Meta/Attribute_Name = 'FlatFile_Template'">
<xsl:value-of select="INBND_META_DATA/Interface_MetaData/Meta/Attribute_Value"/>
</xsl:if>
</Flatfile_Template>
</MetaData>
</FF_META_DATA>
</xsl:template>
</xsl:stylesheet>

But it Maps the wrong Attribute_Value content to FlatFile_Template.

What am I missing here??? I'm sure is simple ... but I can't see it or figure it out.

Any assistance is appreciated.

Postnext
Ivan PedruzziSubject: XSLT Mapping XML to XML: Repeating Attribute Value Pairs to Flat structure
Author: Ivan Pedruzzi
Date: 13 Dec 2006 12:02 PM
HI James

Have a look to the attached solution.

Hope this helps.
Ivan Pedruzzi
Stylus Studio Team


DocumentSAP.xsl

Posttop
james nuzzoSubject: XSLT Mapping XML to XML: Repeating Attribute Value Pairs to Flat structure
Author: james nuzzo
Date: 13 Dec 2006 01:42 PM
Many thanks ... that did the trick ...my logic was abit out of sequence.

Much appreciated

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.