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
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Edwin LanckbeenSubject: Mapping content based instead of schema based.
Author: Edwin Lanckbeen
Date: 31 Aug 2004 05:45 AM
Hi,

Is there a way to extent the mapper with a content based mapping function?
You would be the first!
I’m asking this question because I have to transform many XML files coming from a system who export all data in the same generic schema.
see attached sample file.
The system defines all fields as attributes in stead of elements.
In the end the mapper is useless for these kind of files and I have to write all mappings manually.


Documentsample(1).xml
Sample XML file

Posttop
Ivan PedruzziSubject: Mapping content based instead of schema based.
Author: Ivan Pedruzzi
Date: 31 Aug 2004 10:53 AM
Hi Edwin,

You could try a 2 steps process. Use the following XSLT to get a structure driven document, then use mapper to do the second step.
Hope this helps
Ivan

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:Table="urn:www.x2.com/Formats/Table" >

<xsl:output method="xml"/>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="Table:Field">
<xsl:element name="{@name}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>

<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

 
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.