• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transformation Challenge. Transform Tag data into Tag names

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I have the following 2 XML files:

The content of a pname Tag matches the content of the name tag in the parameters file. Now I want to create an XML where the ids of the pnames become the tag names for the Parameter values. Can you do this using XLST or would I need some Java code?
The reuslt should look like this:

Some Parameter Names might not have expressions in the pname file. Then they should be converted without mapping: <name>paul</name> changes to <paul>...
Thx for helping
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use <xsd:element> and <xsd:attribute> tags in your XSL to generate tags with a dynamically resolved tag name.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lasse,
thx for the info. I already got there. This is my stylesheet so far:


What I need to do: My parameter names (that come from a legacy application) do not have a valid XML format (e.g. "SAP R/3" contains 2 illigal chars namely space and / ).
What I need to do is a "lookup" on the parameter name in the second XML file and retrieve the XML compliant name there. Also for testing purposes: How can I match the stuff (a new stylesheet), so I can get a list of missing Tagname mappings?

Thx for helping!
;-) stw
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stephan H. Wissel:
What I need to do is a "lookup" on the parameter name in the second XML file and retrieve the XML compliant name there.


The document() function should be a good starting point.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved. I post my solution for lookup. I changed the format of one of the XML files to make it easier to look at. The transformation is partially fail save. If a parameter name is not found in pnames the original name is used (This one needs to be XMl compliant then).
parameter.xml

pnames.xml

insertpnames.xlst
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic