remote stylesheet reference (xml newbie)

Discussion in 'XML & RSS' started by motheherder, May 1, 2007.

  1. #1
    hello

    I am trying to set up remote access to an .xsl stylesheet I have created but seem to be encountering some problems. The basic idea is for remote users to be able to use my .xsl stylesheet to transform their .xml docs. When referencing the stylesheet locally it works fine.

    <?xml-stylesheet href="mystylesheet.xsl" type="text/xsl" ?>

    but when placing the .xsl on the server and trying to reference it using a full path I am unable to do so unless my xml file is in the same area on the server? obviously this is not ideal for remote users.

    <?xml-stylesheet href="http://www.mywebsite/xml/mystylesheet.xsl" type="text/xsl" ?>

    Any ideas or assistance much appreciated

    mo
     
    motheherder, May 1, 2007 IP
  2. motheherder

    motheherder Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello

    sorry I failed to mention that the .xsl stylesheet I wish to make available is referncing a .js file which I believe is where the remote access problem lies and not with the .xsl as originally suspected

    thank you

    mo
     
    motheherder, May 8, 2007 IP
  3. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Do you really need to reference that .js file ?
    I've worked with many .xsl files and the files I need to reference (with xsl:include or xsl:import) are always other .xsl files with templates, variables, etc.
     
    ajsa52, May 13, 2007 IP
  4. motheherder

    motheherder Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for your response ajsa52

    the .js file contains numerous rather convoluted functions that combined are able to convert between geographic coordinate systems. If there is a way to include these functions directly in the stylesheet without having to reference the .js file I am open to suggestions. I did try to include the code directly in the stylesheet (if done correctly would this work in terms of remote access?) but it bugged hence the reference to the .js file solution

    any suggestions/comments always welcome
     
    motheherder, May 14, 2007 IP
  5. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Example of method 1 (referencing .js file). This method is to apply XSLT transformation on server:

    
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xsl:stylesheet
       version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
    
    <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"/>
        <script src="../js/yourfile.js" language="JavaScript" type="text/javascript"></script>
      </head>
      <body>
      <!-- Your content goes here -->
      </body>
    </html>
    </xsl:template>
    
    </xsl:stylesheet>
    
    Code (markup):
    Example of method 2 (inserting content of .js file):

    
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xsl:stylesheet
       version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
    
    <xsl:param name="p_position" select="'6'"/>
    
    <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"/>
    
        <script type="text/javascript">
          <xsl:comment>
            <!-- Insert your javascript code here (example) -->
            if ( top.frames.length!=0 )
              top.location = self.document.location;
            <!-- Also you can use xslt syntax like this -->
            var variable1 = <xsl:value-of select="$p_position"/>;
          </xsl:comment>
        </script>
    
      </head>
      <body>
      <!-- Your content goes here -->
      </body>
    </html>
    </xsl:template>
    
    </xsl:stylesheet>
    
    Code (markup):
     
    ajsa52, May 14, 2007 IP