May 23, 200322 yr Newbies I have the following specific problem.. I have xml-files which have the following general format: ... ... ... <object id="11534" type="6"> <property id="393228"> <int>33554431</int> </property> </object> ... ... ... where a property can (instead of type int) be a object again, or a objref, or a simple type. I want to use xslt to transform this format, to something more specific like: <object6 id="11534"> <property id="393228"> <int>33554431</int> </property> </object6> (So object types can be distinguished by looking only at the name of the tag.) Can anyone tell me how to do the above transform? Thanks in advance, Britz .......................................................................... The background info.... I use a program (J.D Edwards Solution Modeler) to generate processmodels. This program exports to xml. The goal is to create a conversion tool that converts any xml-file created with this program to the PNML-standard. (Petri-net standard of xml) I have the xml-schema of the pnml-standard, but the problem is that i haven't got the XML-schema of the source file. Furthermore, the people of J.D Edwards didn't make it easy to do by hand, as the xml-file is terrible to read for the (not so trained) human eye. I use XMl-spy to generate a XMl-schema from the xml-file , but the schema is far to generic to be of any use. Therefore i want to transform the xml-file, in such a way that xml-spy generates a more specific xml-schema. Then i can go and make a xslt-schema to transform one xml-schema to the other.
May 23, 200322 yr Probably not the right list for such a specific non-FileMaker XSLT question, but here is a working code snippet: <xsl:for-each select="object"> <xsl:variable name="temp"> <xsl:value-of select="name()"/> <xsl:value-of select="@type"/> </xsl:variable> <xsl:element name="{$temp}"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute><xsl:value-of select="*"/></xsl:element> </xsl:for-each>
May 23, 200322 yr Author Newbies Thanks for your reply. I'm an newbie to XSL(T) so bplease bare with me.. I used your code-snippet to make the following xslt-file but it gave an error, van you tell me what's wrong? ----- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:for-each select="object"> <xsl:variable name="temp"> <xsl:value-of select="name()"/> <xsl:value-of select="@type"/> </xsl:variable> <xsl:element name="{$temp}"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute><xsl:value-of select="*"/></xsl:element> </xsl:for-each> </xsl:stylesheet> Thanks in advane, Geert-Jan Brits The Netherlands
May 23, 200322 yr >I use XMl-spy to generate a XMl-schema from the xml-file , but the schema is far to generic to be of any use. Therefore i want to transform the xml-file, in such a way that xml-spy generates a more specific xml-schema. Then i can go and make a xslt-schema to transform one xml-schema to the other. the <xsl:template> tags ar missing, the correct XPATH for the object (its position in the XML tree) will have to be added. XML Spy should give you the basic "strawman" you need for XML-XML conversion. Simply replace the references to /.?./.?./?./object* with the code snippet. Reverse-engineering a Schema is not really a project for someone completely new to XML and XSLT, though. Took me weeks to get into this.
May 24, 200322 yr Author Newbies thanks i will look into it. I'm not completely new to xml though, but as you said, it's rather difficult
Create an account or sign in to comment