Re: Transformation XML to Datapacket

Hi Pierre,

> I do use Xml file, I need to convert the file to xml datapacket.
>
> I want the attribute fieldname of the datapacket get the caption
> value of the field.
> Something like the following for the field "Name":
> fieldname=value of the caption of the field.

First, I think that you're addressing this question to the wrong forum
-- xmlschema-dev@w3.org is concerned with XML Schema rather than
transforming XML.

Second, it looks as though you're creating your own transformation
language to describe the transformation that you want to make. You
might find it easier to use an existing transformation language, such
as XSLT, instead, or perhaps to transform your transformation language
to XSLT so that you can take advantage of those tools. A simplified
XSLT stylesheet for the transformation you appear to wish to make is:

<DATAPACKET Version="2.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xsl:version="1.0">
  <METADATA>
    <FIELDS>
      <FIELD attrname="No_" fieldtype="string" WIDTH="13"/>
      <FIELD attrname="Name" fieldtype="string" WIDTH="28"/>
    </FIELDS>
    <PARAMS/>
  </METADATA>
  <ROWDATA>
    <xsl:for-each select="/tst/Customer">
      <ROW No_="{No_}" Name="{Name}"
           Search_Name="{Search_Name}" City="{City}" />
    </xsl:for-each>
  </ROWDATA>
</DATAPACKET>

Note that XSLT 1.0 doesn't use information from a schema to perform a
transformation. This feature is added in XSLT 2.0.

I suggest you direct questions about XSLT to XSL-List@mulberrytech.com
(see http://www.mulberrytech.com/xsl/xsl-list).

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Wednesday, 19 June 2002 06:06:28 UTC