qbektrix / xml2json-xslt

Automatically exported from code.google.com/p/xml2json-xslt
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Missing brace when node is null #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
  <!-- item:null -->
  <xsl:template match="*[count(child::node())=0]">
    <xsl:call-template name="escape-string">
      <xsl:with-param name="s" select="local-name()"/>
    </xsl:call-template>
    <xsl:text>:null</xsl:text>
    <xsl:if test="following-sibling::*">,</xsl:if>
    <xsl:if test="not(following-sibling::*)">}</xsl:if>
  </xsl:template>

you forgot the brace, please fix:)

thanks

Original issue reported on code.google.com by sse...@googlemail.com on 17 Jun 2008 at 7:19

GoogleCodeExporter commented 9 years ago
I was able to recreate this with:

<items>
  <item>
    <id>1</id>
    <labels></labels>
  </item>
  <item>
    <id>2</id>
    <labels></labels>
  </item>
</items>

Original comment by chiol...@gmail.com on 12 Nov 2010 at 11:45

GoogleCodeExporter commented 9 years ago
I'm also able to generate invalid JSON with:

<item>
</item>

which produced:

items:null}

Note the missing open-brace.

I was able to solve it with:

<xsl:if test="not(preceding-sibling::*)">{</xsl:if>

as the first rule of item:null. I have not run it against the rest of the unit 
tests, though.

Original comment by chiol...@gmail.com on 29 Nov 2010 at 8:13