XSLt.transform gives me "d»z"

Posted by phenevo on Stack Overflow See other posts from Stack Overflow or by phenevo
Published on 2010-05-07T09:48:58Z Indexed on 2010/05/12 0:24 UTC
Read the original article Hit count: 972

Filed under:
|
|
|

Hi,

I have XML:

<results>
    <Countries country="Albania">
        <Regions region="Centralna Albania">
            <Provinces province="Durres i okolice">
                <Cities city="Durres"
                            cityCode="2B66E0ACFAEF78734E3AF1194BFA6F8DEC4C5760">
                    <IndividualFlagsWithForObjects Status="1" />
                    <IndividualFlagsWithForObjects  Status="0" />
                    <IndividualFlagsWithForObjects status="2" />
                 </Cities>
             </Provinces>
        </Regions>
    </Countries>
    <Countries .... 

Which is result of this part of query:

SELECT Countries.FileSystemName as country,
       Regions.DefaultName as region ,
       Provinces.DefaultName as province,
       cities.defaultname as city,
       cities.code as cityCode, 
       IndividualFlagsWithForObjects.value as Status

I have xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text" encoding="iso-8859-1"/>

  <xsl:param name="delim" select="string(',')" />
  <xsl:param name="quote" select="string('&quot;')" />
  <xsl:param name="break" select="string('&#xD;')" />

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

  <xsl:template match="countries">
    <xsl:apply-templates />
    <xsl:if test="following-sibling::*">
      <xsl:value-of select="$break" />
    </xsl:if>
  </xsl:template>

  <xsl:template match="*">
    <!-- remove normalize-space() if you want keep white-space at it is -->
    <xsl:value-of select="concat($quote, normalize-space(.), $quote)" />
    <xsl:if test="following-sibling::*">
      <xsl:value-of select="$delim" />
    </xsl:if>
  </xsl:template>

  <xsl:template match="text()" />
</xsl:stylesheet>

And is part of code

XmlReader reader = cmd.ExecuteXmlReader();

doc.LoadXml("<results></results>");
XmlNode newNode = doc.ReadNode(reader);

while (newNode != null)
{
    doc.DocumentElement.AppendChild(newNode);
    newNode = doc.ReadNode(reader);
}                    

doc.Save(@"c:\listOfCities.xml");

XslCompiledTransform XSLT = new XslCompiledTransform();    
XsltSettings settings = new XsltSettings();    
settings.EnableScript = true;

XSLT.Load(@"c:\xsltfile1.xslt", settings, new XmlUrlResolver());

XSLT.Transform(doc.OuterXml,@"c:\myCities.csv");

Why now I have in my csv only one cell with value : d»z

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml