• 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

xhtml to xhtml using xslt

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to use xslt to convert xhtml to xhtml, just changing the attributes of some elements(img and a). It's all going well, except the output I'm getting is all the elements in the order they apear in the origonal. Here is my code:

How can I make it so's the node tree stays the same, with just my changes to the attributes of those elements?
Regards,
Brendan
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was just curious, and used your xslt to transform a very simple xhtml file to a new one, and got a totally wrong result. How could it work fine for you.
I'm using xalan transformer...
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its too difficult to look for a solution if one sees only part of the problem.
So you might post your xml input file.
For me the xslt debugger of WSAD is a great help to understand xslt/xPath. XMLSpy seems to have similar feature in their version 5, which is even better because it shows output.
It surely is an efective help for problems like yours.


from xml-spy site:
Step through an XSLT transformation process line-by-line with a 3-panel interface that displays the input XML document (with context node highlighted), the XSLT stylesheet (with current node highlighted), and the output document as it is being built in real-time.


http://www.xmlspy.com/features_xsl.html
Don't know if there are any openSource solutions for that.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use the identity template, and then add specific templates for your specific elements/attributes.
identity template
Good luck!
 
Brendan Kennedy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies
the xsl wasn't working totally fine. it was working ok in that the img tag was getting changed in the way I wanted. The elements were being sorted into the order they apeared in in the origonal file, ie with no children. I'm using xml spy 4.3 and (I think) the msxml parser.
The files I'm using are at :
http://www.redbrick.dcu.ie/~keno/ranch/
The other xsl there is trying it using templates.
I haven't gotten working with the identity template yet, hopefully that does it
Thanks again
Brendan
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The identity template will guarantee you have everything else work correct. You need only to focus on the elements you need to change. Your original code on attribute has a problem, which is that if img tag has width/height/etc. other attributes, they will be lost.
I might try to make it work when I've some time, but it is not a promise.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your answer here:
Q. How to tranform an xhtml file to an identical xhtml with the exceptions of adding prefix path to src/href attribute value?
Try to display the original xhtml to see all the broken images and link. Then use the xslt to tranform it to a new xhtml to see it live and beautiful. I think You would love it!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic