test returned xml for a value and change the output from it.
This is an open discussion with 4 replies, filed under XSLT.
Search
For better legibility, I've formatted the code:
<OneBoxResults> <resultCode>success</resultCode> <provider>unit_testing</provider> <MODULE_RESULT> <U>http://www.myserver.com/page3.html</U> <FIELD name="catalog_number">509-BOD</FIELD> <FIELD name="description">Starter,SIZE 1,115-120V 60Hz,Open Relay</FIELD> <FIELD name="partially_validated">1</FIELD> </MODULE_RESULT> </OneBoxResults>
You were so close. Remove the slash after the FIELD node selector in the XPath:
<xsl:choose> <xsl:when test="/OneBoxResults/MODULE_RESULT/FIELD[@name='partially_validated'] = '1'">Partially validated = 1</xsl:when> <xsl:otherwise>Partially validated = 0</xsl:otherwise> </xsl:choose>
Thank you so much for your help.
I have put the code in as you stated and there are no more errors. But the test never matches on a '1' condition. I have placed a line in there to output the value of "partiallyvalidated" and see that it toggles, but the "when test" line never switches.
Let me be a little more help.
This returns partiallyvalidated = 1
[link text][1]
This returns partially_validated = 0
[link text][2]
[1]: http://dev.symx.com/raconfig/validate-google.asp?query=509-B"Partially Validated = 1
[2]: http://dev.symx.com/raconfig/validate-google.asp?query=509-BOD"Partially Validated = 0
Again thanks John
I finally got it working by not including the root path /OneBoxResults/ AND taking the single quotes off the "1" at the end. NOTE: I also pointed to the first result which had no bearing on this not working.
<xsl:choose> <xsl:when test="MODULE_RESULT[1]/FIELD[@name='partially_validated']=1"> Partially validated = 1</xsl:when> <xsl:otherwise>Partially validated = 0</xsl:otherwise> </xsl:choose>
Create an account or sign in to comment.
Here is the returned xml
<OneBoxResults> <resultCode>success</resultCode> <provider>unit_testing</provider> <MODULE_RESULT> <U>http://www.myserver.com/page3.html</U> <FIELD name="catalog_number">509-BOD</FIELD> <FIELD name="description">Starter,SIZE 1,115-120V 60Hz,Open Relay</FIELD> <FIELD name="partially_validated">1</FIELD> </MODULE_RESULT> </OneBoxResults>
How do I test that partially_validated is a one or zero and change the output because of it? I tried this and many more versions with no success:
<xsl:choose> <xsl:when test="/OneBoxResults/MODULE_RESULT/FIELD/[@name='partially_validated']='1'"> Partially validated = 1 </xsl:when> <xsl:otherwise> Partially validated = 0 </xsl:otherwise> </xsl:choose>
Thank you for any help you can give John