bsuh / node_xslt

a simple XSLT addon for node
zlib License
71 stars 17 forks source link

Converting xsl to stylesheet object returns nothing. #28

Closed ghost closed 9 years ago

ghost commented 9 years ago

Trying to convert and xsl file to an object using readXsltFile .. this returns an empty object {} Also converting the xsl to a string. Then attempting to run readXsltString. Also returning an empty object {} No errors...

The xsl is valid.

Any ideas on how i can proceed?

andreyvital commented 9 years ago

Sure. I might see your input?

ghost commented 9 years ago

@andreyknupp

I am trying with a fairly long xsl doc. However I even tried with simple xsl. And it still does not work.

Here is the simple xsl.

filename: helloworld.xsl

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/hello-world">
    <HTML>
      <HEAD>
        <TITLE></TITLE>
      </HEAD>
      <BODY>
        <H1>
          <xsl:value-of select="greeting"/>
        </H1>
        <xsl:apply-templates select="greeter"/>
      </BODY>
    </HTML>
  </xsl:template>
  <xsl:template match="greeter">
    <DIV>from <I><xsl:value-of select="."/></I></DIV>
  </xsl:template>
</xsl:stylesheet>

I run

stylesheet = xslt.readXsltString(fs.readFileSync(path.join(__dirname,'helloworld.xsl'), 'utf8'));

I get an empty object {}

andreyvital commented 9 years ago

Sure, but the transform is still working? I really think that there's no return on readXsltString, I mean, propertyless in the returned object.

I'll check this out soon, Thanks.

ghost commented 9 years ago

@andreyknupp

I believe you are correct! The return object is propertyless. Apart from proto

andreyvital commented 9 years ago

Oukay, sorry for the late reply.

The transform is working fine; yes, those returned objects of readXsltFile and readXsltString are propertyless as I've said.

var xslt = require('node_xslt');

var result = xslt.transform(
    xslt.readXsltFile('helloworld.xsl'),
    xslt.readXmlString(
        '<?xml version="1.0"?><hello-world><greeting>vageez</greeting></hello-world>'
    ),
    []
);

console.log(result);

Output

<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE></TITLE>
</HEAD>
<BODY><H1>vageez</H1></BODY>
</HTML>

Well, closing then. :beers:

ghost commented 9 years ago

Yes. Great. Thank you :)