• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 797
  • Last Modified:

XML encoding

I have a xml file - gigs.xml
I have a xsl file - gigs_edit.xml
I have an asp file - gigs_edit.asp

The xsl styles the xml and it is pulled into the browser through the asp file.
However I get this error - "System does not support the specified encoding"

Here is my xml
_________________________________________


<?xml version="1.0" encoding="UTF-16"?>

<sexmachina>
      <gig id="0" online="1" played="0">
            <city>Oxford</city>
            <venue>Kiss Bar</venue>
            <date>Tuesday 26th April</date>
            <mapUrl></mapUrl>
            <support>
                  <band1>
                        <name>cassette for cassette</name>
                        <url>http://www.jitter.co.uk/cfc/index.html</url>
                  </band1>
                  <band2>
                        <name>we the starling</name>
                        <url></url>
                  </band2>
                  <band3>
                        <name></name>
                        <url></url>
                  </band3>
            </support>
            <notes>dasdsdf</notes>
      </gig>
</sexmachina>


Here is my XSL
______________________________________________

<?xml version="1.0" encoding="UTF-16"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-16" version="1.0"/>

<xsl:template match="/">
      <xsl:apply-templates />
</xsl:template>

<xsl:template match="/gigs">
      <html>
      <head>
            <title>sexmachina</title>
            <link rel="stylesheet" type="text/css" href="../styles.css" />
            <script type="text/javascript" src="../js/misc-scripts.js"></script>
      </head>


      <body onload="self.focus();">


      <table border="0">
            <tr>
                  <td>
                        <table width="100%">
                              <tr>
                                    <td valign="bottom"><span class="title">sexmachina</span></td>
                              </tr>
                              <tr>
                                    <td valign="bottom">
                                          <span class="title">gigs</span>
                                          <a class="norm" href="gigs_new.asp">add new date</a>
                                          <a class="norm" href="options.asp">back to options</a>
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
            <tr>
                  <td height="10"></td>
            </tr>

            <xsl:for-each select="gig">


                  <tr>
                        <td>
                              <table>
                                    <tr>
                                          <td width="100"><span class="gen"><xsl:value-of select="city" /></span></td>
                                          <td width="200"><span class="gen"><xsl:value-of select="venue" /></span></td>
                                          <td width="180"><span class="gen"><xsl:value-of select="date" /></span></td>
                                          <td width="30"><a class="norm" href="gigs_details.asp?id={@id}">edit</a></td>
                                          <td width="40"><a class="norm" href="gigs_delete_confirm.asp?id={@id}&amp;city={city}&amp;venue={venue}&amp;datex={date}">delete</a></td>
                                                                  
                                    </tr>
                                    <tr>
                                          <td height="10"></td>
                                    </tr>
                              </table>
                        </td>
                  </tr>            
            </xsl:for-each>

      </table>


      </body>
      </html>
</xsl:template>      


</xsl:stylesheet>




Here is my ASP
__________________________________

xml = Server.MapPath("..\xml\gigs.xml")
xsl = Server.MapPath("..\xml\gigs_edit.xsl")
 
Set objXML = Server.Createobject("Microsoft.XMLDOM")
objXML.validateOnParse = true
objXML.async = false
objXML.load(xml)

Set objXSL = Server.Createobject("Microsoft.XMLDOM")
objXSL.validateOnParse = true
objXSL.async = false
objXSL.load(xsl)

Response.Write (objXML.transformNode(objXSL))



Can anyone help. It just seems like it's being annoying on purpose.

Thanks,
Dave




0
weerdboil
Asked:
weerdboil
  • 4
  • 3
1 Solution
 
b1xml2Commented:
ASP Code
======
xml = Server.MapPath("..\xml\gigs.xml")
xsl = Server.MapPath("..\xml\gigs_edit.xsl")
 
Set objXML = Server.CreateObject("Msxml2.DOMDocument")
objXML.validateOnParse = true
objXML.async = false
objXML.load(xml)

Set objXSL = Server.CreateObject("Msxml2.DOMDocument"")
objXSL.validateOnParse = true
objXSL.async = false
objXSL.load(xsl)


objectXml.transformNodeToObject objXSL,Response
0
 
b1xml2Commented:
encoding should be either UTF-8 or ISO-8859-1

UTF-16 is not to be used for transformations...
0
 
b1xml2Commented:
thus,
Xml
===
<?xml version="1.0" encoding="UTF-8"?>
....

Xslt
===
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8" version="1.0"/>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
weerdboilAuthor Commented:
thanks alot.
0
 
weerdboilAuthor Commented:
hmmm. it just stopped working - hope you can help again.
I'm working on a different page. These encode settings are really confusing. no matter what I change it to (UTF-8, IS-8859-1 or even windows-1252) in both the XML and XSL docs the error still shows:

here is the xslt:

<?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="xml" encoding="ISO-8859-1" version="1.0"/>

<xsl:template match="/">
      <xsl:apply-templates />
</xsl:template>

<xsl:template match="/gigs">
      <html>
      <head>
            <link rel="stylesheet" type="text/css" href="styles.css" />
            <script type="text/javascript" src="js/misc-scripts.js"></script>
            <title>sexmachina</title>
      </head>


      <body class="white">

      <div class="pos" style="margin-left: -380px; margin-top: -250px; width: 760px; height: 460px; border: 0px solid #D2D1C7;">

            <span class="pos" style="top: 80px; left:80px;">
                  <img src="images/rosa_brown_sma.jpg" galleryimg="no" />
            </span>

            <span class="pos" style="top: 300px; left: 30px;">
                  <a href="sexmachina.asp?ret=y"><img src="images/logo_black.gif" /></a>
            </span>

            <!-- #include file="nav.asp" -->

            <span class="pos" style="top: 30px; left: 360px;">
                  <span class="gen">see Sexmachina live...</span>
            </span>

            <span class="scroll" style="top: 65px; left: 360px; width: 380px; height: 320px; ">
                  <table width="100%">


                  <xsl:for-each select="gig">
                        <xsl:sort select="@dateSort" data-type="number" order="ascending" />

                        <tr>
                        <xsl:choose>
                              <xsl:when test="@played = 1">
                                    <td width="100"><span class="grey"><xsl:value-of select="city" /></span></td>
                                    <td><span class="grey"><xsl:value-of select="venue" /></span></td>
                                    <td align="right">
                                          <span class="grey">
                                                <xsl:value-of select="@day" />&#160;
                                                <xsl:value-of select="@date" />&#160;
                                                <xsl:value-of select="@month" />
                                          </span>
                                    </td>
                              </xsl:when>
                              <xsl:otherwise>
                                    <td width="100"><span class="gen"><xsl:value-of select="city" /></span></td>
                                    <td><span class="gen"><xsl:value-of select="venue" /></span></td>
                                    <td align="right">
                                          <span class="gen">
                                                <xsl:value-of select="@day" />&#160;
                                                <xsl:value-of select="@date" />&#160;
                                                <xsl:value-of select="@month" />
                                          </span>
                                    </td>
                              </xsl:otherwise>
                        </xsl:choose>
                        </tr>
                        
                  </xsl:for-each>
                  
                  </table>
            </span>

      </div>
</body>
</html>


</xsl:template>

</xsl:stylesheet>


0
 
b1xml2Commented:
what's the Xml data and what;s your ASP code.
0
 
weerdboilAuthor Commented:
sorry it's taken so long to get back to this issue. this is my problem as it currently stands:

i want to use xml as my data source. no problem, i've made ASP and XML applications before.

i got to reading that an xsl page would be better to get the XML into the browser. The ability to get a specific set of records back from an XML file seemed a much better option than looping through the whole XML doc in ASP and writing out the records that i wanted depending on database or querystring keys.

so, no problem loading and transforming the xml with the xsl normally. except that sometimes I get "System does not support the specified encoding." errors even when the encoding is set to the same in each file. what could be wrong here? I have it set to windows-1252 as it seems work most. unsupported characters perhaps?


anyway, here are some code snippets:

xml
<sexmachina>
     <stream id="0">
          <song>no_appeal</song>
          <dateTime>3/7/2005 10:59:53 AM</dateTime>
          <ipAddress>no ipAddress</ipAddress>
     </stream>
     <stream id="1">
          <song>moth_day</song>
          <dateTime>3/8/2005 11:25:04 AM</dateTime>
          <ipAddress>no ipAddress</ipAddress>
     </stream>
</sexmachina>


i have no problem getting this out onto the page ans styled exactly how I want using this xsl

<xsl:for-each select="stream">
     <xsl:sort select="dateTime" data-type="number" order="descending" />

     <xsl:element name="a">
          <xsl:attribute name="class">noHand</xsl:attribute>
          <xsl:attribute name="style">width: 100;</xsl:attribute>                        
             <xsl:attribute name="href">streams.asp?song=<xsl:value-of select="song" /></xsl:attribute>
             <xsl:value-of select="song" />
        </xsl:element>
         
     <span class="gen" style="width: 200; text-align: right;"><xsl:value-of select="dateTime" /></span>&#160;&#160;&#160;&#160;              
     <span class="gen" style="width: 180; text-align: right;"><xsl:value-of select="ipAddress" /></span>
                   
     <br />
                   
</xsl:for-each>    


but how do i manipulate this data dynamically say with either a querystring, or to a client side javascript???
i saw this to manipulate a xml object clientside:

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxsl="urn:schemas-microsoft-com:xslt"
     xmlns:dates="urn:rdcpro-com:dates">

<msxsl:script language="JScript" implements-prefix="dates">
     <![CDATA[

     function loadXML(xmlFile)
     {
          var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async="false";
            //xmlDoc.onreadystatechange=verifyXML;            
            xmlFile = "../xml/streams.xml"
          xmlDoc.load(xmlFile);
          xmlObj=xmlDoc.documentElement;          
         
          return(xmlObj);
     }
         
     ]]>
         
</msxsl:script>



but all i would expect to do here is build a long html string based on a parameter value and then display on screen in a div/span tag, and this doesn't seem like the best way as otherwise what is the point of all that <xsl:when> and <xml:otherwise> etc etc??

hope someone can give me some more pointers.

thanks very much
dave
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now