• 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

XSLT in XML

 
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I've a .xml and .xsl file.
How to specify xslt path in XML

I've written the following statement in my xml file :-


But I get below error when opened in Opera

This document had no style information.



Please advise.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "href" attribute should be a URL. A Windows file path is not a URL. And even if you did make it a file:// URL the chances are that a browser would reject it on security grounds. Your best bet is to make the URL a relative one, that should be relative to the URL where the XML document was loaded from.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

How to make a file path as a relative url ?

My xml file path is : - C:\Users\Pramod\Desktop\1.xml
and xsl is :- C:\Users\Pramod\Desktop\cdcatalog.xsl

Could you please give me some example.

I tried out few combinations but nothing worked out.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pramod talekar wrote:How to make a file path as a relative url ?

My xml file path is : - C:\Users\Pramod\Desktop\1.xml
and xsl is :- C:\Users\Pramod\Desktop\cdcatalog.xsl

Could you please give me some example.



Well, "some example" isn't what you are asking for, right? You start with the directory of the XML file. That's your base directory as far as the browser is concerned. (Sort of like the current working directory.) Then the relative URL of the XSL file is the path relative to that base directory. Also remember that you don't use backslashes in a URL.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

So is it <?xml-stylesheet type="text\xsl" href="C:/Users/Pramod/Desktop/cdcatalog.xsl"?>

 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. As I said before, that isn't a URL. You must have overlooked that.

Let's take it one small step at a time. What's the base directory for your XML document?
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My base directory is "C:/Users/Pramod/Desktop/".
Both files are kept on Desktop. I read somewhere that if both the xml and xslt files share the same path then it's not needed to mention the full path name in xsl:stylesheet.
So I tried writing href="cdcatalog.xsl" & "/cdcatalog.xsl" but it didn't work.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


<?xml-stylesheet type="text\xsl" href="cdcatalog.xsl"?>



Try "text/xsl" instead. forward slash instead of backward one.

regards,
Amit
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amit, You Rock !!
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Thanks but no thanks.
This came to the rescue. Check here.

Regards,
Amit
 
I'm doing laundry! Look how clean this tiny ad is:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic