Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

using xslt to generate more meaningful xml-schema

Featured Replies

  • 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.

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>

  • 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

>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.

  • Author
  • Newbies

thanks i will look into it. I'm not completely new to xml though, but as you said, it's rather difficult smile.gif

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.