1

Original source of xml

<SubdivisionType>
         <ID>null</ID>
         <Name>null</Name>
         <Parent i:nil="true"/>
</SubdivisionType>

String 'null' is generated by E4X. I have to check if SubdivisionType/ID contains another value then 'null' then skip all SubdivisionType tag.

Here is how i do

<xsl:if test="SubdivisionType/ID[text()!=null]" >
   ...
</xsl:if>

I can't understand how xlst(saxon) treats string 'null'.

1
  • Saxon or any other XSLT processor treats it like any other string. Commented Jun 19, 2015 at 9:59

2 Answers 2

1

I don't know saxon specifically, but as far as I'm aware, that isn't a "null string"... it's a string with the value "null".

I would try changing...

text()!=null

to...

text()!='null'

so that it reads...

<xsl:if test="SubdivisionType/ID[text()!='null']">
Sign up to request clarification or add additional context in comments.

Comments

0

@Simar,

if we conside below as the xml

<?xml version="1.0" encoding="utf-8"?>
<xml>
<SubdivisionType>
<ID>null</ID>
<Name>null</Name>
<Parent nil="true"/>
</SubdivisionType>
<SubdivisionType>
<ID>asd</ID>
 <Name>null</Name>
<Parent nil="true"/>
</SubdivisionType>
</xml>

XSL:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" `xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy> 
</xsl:template>
<xsl:template match = "SubdivisionType[ID = 'null']" />
</xsl:stylesheet>

OUTPUT :

<?xml version="1.0" encoding="UTF-8"?>
<xml>
<SubdivisionType>
<ID>asd</ID>
<Name>null</Name>
<Parent nil="true"/>
</SubdivisionType>
</xml>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.