0

I am trying to convert this xsl statement,because on windows server 2008 the selectSingleNode is not supported and the if statement I wana writet it in a more supported way on WS2008.

So with the below code I get the following error:

"ABC" is not a valid XSLT or XPath function

Currrent Code to be converted:

  <xsl:if expr='ContractAddress(selectSingleNode("AddressNo").text,selectSingleNode("/Object/Contract/ConAddrNo").text)'>...</xsl:if>

so please help on how to convet the above code I am using the following namespace:

<xsl:stylesheet version="1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:msxsl = "urn:schemas-microsoft-com:xslt" xmlns:vbs = "urn:schemas-sqlxml-org:vbs" xml:space="preserve">

Example XML:

<Address>
  <ConAddrNo>123</ConAddrNo>
</Address> ... <Contract>
  <AddressNo>123</AddressNo>
</Contract>

Current XSLT:

<xsl:if expr='ContractAddress(selectSingleNode("AddressNo").text, selectSingleNode("/Object/Contract/ConAddrNo").text)'>
  <xsl:eval> FormatAddress(selectSingleNode("Line1").text, selectSingleNode("Line2").text, selectSingleNode("Line3").text, selectSingleNode("Line4").text, selectSingleNode("PostalCode").text) </xsl:eval>
</xsl:if>
JLRishe
  • 99,490
  • 19
  • 131
  • 169
TMAN-MAN
  • 141
  • 1
  • 2
  • 13
  • What are you attempting to accomplish with that line of code? The only parts of it that are valid XSLT are the `` at the end. What is the `ContactAddress()` function supposed to do? – JLRishe Mar 18 '13 at 14:43
  • Function Contact Address() needs to test if AddressNo is the same as ConAddrNo. function ContractAddress(AddrNo, ConAddrNo) if AddrNo = ConAddrNo then ContractAddress = 1 else ContractAddress = 0 end if end function So from the Code I need to change I take those values from my XML file and wana pass them to ContactAddress Function to test and so if they are the same I want to execute something inside that xsl if statement – TMAN-MAN Mar 18 '13 at 14:56
  • You don't need a special function to do that. Could you show us a larger portion of your XSLT encompassing that `xsl:if`, and a sample of the XML input? – JLRishe Mar 18 '13 at 15:02
  • XML Input:
    123
    ... 123 then My XSLT Code : FormatAddress(selectSingleNode("Line1").text, selectSingleNode("Line2").text, selectSingleNode("Line3").text, selectSingleNode("Line4").text, selectSingleNode("PostalCode").text)
    – TMAN-MAN Mar 18 '13 at 15:18
  • There is no `` in XSLT 1.0. Correct would be ``. Your code should not work at all. Can you explain what `expr` is supposed to be? What set-up are you using? Also, `ContractAddress(selectSingleNode("AddressNo").text,selectSingleNode("/Object/Contract/ConAddrNo").text)` is anything, but not an XPath expression. – Tomalak Mar 18 '13 at 15:29
  • 3
    In future, when asked for additional example code, please add it to the question, not the comments. Also, is what you just provided your entire XSLT? What are you using as a reference to construct this XSLT? As Tomalak says, `xsl:if` does not have an `expr` attribute, and there is no XSLT element named `xsl:eval`. – JLRishe Mar 18 '13 at 15:35
  • @JLRishe `xsl:eval` comes from the old "working draft" version of XSL (namespace `http://www.w3.org/TR/WD-xsl`) as implemented by Microsoft in old versions of IE. Its content is treated as a JavaScript expression calling functions defined in an ``. – Ian Roberts Mar 18 '13 at 16:29
  • @IanRoberts I see. Thank you for clarifying. OP - could you please show us a significantly larger portion of your XSLT? All of it if it's not too large? – JLRishe Mar 18 '13 at 16:34
  • I managed to change the majority of the namespace,but the code I just posted its the one i can not convert to a supported code for windows server 2008...I appreciate all your guidance and answers.Thanx a lot. – TMAN-MAN Mar 19 '13 at 13:00

1 Answers1

2

The xsl:if with an @expr attribute, and the xsl:eval, are instructions from an obsolete Microsoft dialect of XSLT that dates from 1998, before XSLT became a W3C specification. It is very rarely seen nowadays, since Microsoft followed it with a conformant XSLT implementation about a year later.

The dialect is sometimes called WD-xsl, (WD for working draft) after the namespace it uses, though Microsoft itself tended to call it simply "XSL" (as distinct from "XSLT").

I doubt you will find anyone where who's confident enough in WD-xsl to understand your code and translate it.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164