locked
Biztalk XSLT RRS feed

  • Question

  • I am new to use XSLT. i have a requirement where i have to create a node in output schema.

    my input schema is as below

      <?xml version="1.0" encoding="utf-16" ?>
    - <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://XSLTt.Schema1" targetNamespace="http://XSLTt.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    - <xs:element name="Root">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="ID" type="xs:string" />
    - <xs:element name="Payload">
    - <xs:complexType>
    - <xs:sequence>
    - <xs:element name="SpecificConcession">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Address" type="xs:string" />
      <xs:element name="Company" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>

    Inside the map i have used the scripting functoid and used the inline XSLT by using the below code

    <xsl:if test=”//*[local-name()=’SampleConcession’])/*[local-name()=’Name’]”>
    <xsl:element name=”Name”>
    <xsl:value-of select=”//*[local-name()=’SampleConcession’]/*[local-name()=’Name’]”/>
    </xsl:element>
    </xsl:if>

    when i test the map i am getting the fallowing error

    XSl Transform Error:unable to write output instance to the fallowing<> XSlT Compile Error at (8,13) see inner exceptipn for details *[local-name()=’SampleConcession’])/*[local-name()=’Name’ is an invalid xpath expression.*[local-name()=’SampleConcession’])/*[local-name()=’Name’] has an invlaid token

    i am not able to find the cause of this error.

    can anyone help me on this?

    Monday, April 28, 2014 6:06 AM

Answers

  • Hello Sujith,

    i got your email. i have fixed the issue and emailed it to you. Open the solution and check it.

    here is the correct script that you need to use, its quite easy

    <Nmae>
    <xsl:value-of select="/*[local-name()='Sampleschema' and namespace-uri()='http://xsltttttttttttttttt.Schema1']/*[local-name()='SampleDestination' and namespace-uri()='']/*[local-name()='Nmae' and namespace-uri()='']"/>
    </Nmae>

    also you have linked your scripting functiod to root node. you should connect it to element node for this case.


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Proposed as answer by Ravindar Thati Friday, May 2, 2014 5:42 AM
    • Marked as answer by Angie Xu Monday, May 5, 2014 1:31 AM
    Friday, May 2, 2014 5:38 AM

All replies

  • I see an extraneous ")" in your expression after *[local-name()='SampleConcession']. Secondly I do not see the starting "//" or "/".

    Regards.

    Monday, April 28, 2014 6:31 AM
    • Thanks for ur assistance
    • I have changed my code to the below

    <xsl:if test="/*[local-name()='Root' and namespace-uri()='http://XSLTt.Schema1']/*[local-name()='Payload' and namespace-uri()='']/*[local-name()='SpecificConcession' and namespace-uri()='']/*[local-name()='Name' and namespace-uri()='']">
    <xsl:element name="Name">
    <xsl:value-of select="/*[local-name()='Root' and namespace-uri()='http://XSLTt.Schema1']/*[local-name()='Payload' and namespace-uri()='']/*[local-name()='SpecificConcession' and namespace-uri()='']/*[local-name()='Name' and namespace-uri()='']"/>
    </xsl:element>
    </xsl:if>

    now i get the out put as

    name<name_0>name

    but i don t get the schema information

    i have connected my scriptiong functoid to a destination node but the Schema information is not coming

    any idea on how should i change the XSLT?

    Monday, April 28, 2014 7:27 AM
  • Actually it should work, try this

    Replace the following 

    <xsl:element name="Name">  </xsl:element>

    with tag <Name>  </Name>

    if possible also post a screen shot of your map.

    also i see that name_0 is coming as output, That kind of output elements come when map passes auto generated instance of the input schema as input to map. So it implies that actually the xpath you set is working correctly. Just tweak the output format you need. Also make sure you set your input instance path for you map.


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Monday, April 28, 2014 7:51 AM
  • The reason for that is the value returned in <xsl:value-of select>. The XPATH expressions returns the NODE not the value.

    If the only purpose is to create the node then your test should return False and you should output the <Name /> node. The value of which should come from the SOURCE Schema.

    Regards.

    Monday, April 28, 2014 8:35 AM
  • I have attached the Screenshot ogf the Map.you are right i am trying to pass the default instance as an input but my expected o/p from it is

    <ns0:SpecificDestination xmlns:ns0="http://XSLTt.Schema2">
      <Name>Name_0</Name>
    </ns0:SpecificDestination>

    Since i have connected my o/p of scripting functoid to Destination Doesnt it use the same schema whn i am testing the map?

    Monday, April 28, 2014 10:46 AM
  • Your destination schema does not have a field element. It has only a record. create a field inside the record in destination with name "Name". Then it should work.

    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    Monday, April 28, 2014 11:16 AM
  •  I tried by creating a filed element Name still for me its the same result:(
    Monday, April 28, 2014 11:25 AM
  • I think you should switch to Custom XSLT instead of trying to solve this in a scripting Functoid, since all of you logic seems to be XSLT anyway.

    Just do what you want to do mapping wise in a custom .xslt file, and attach it to your map in the "Custom XSLT Path" Property on the Map.

    Morten la Cour

    Monday, April 28, 2014 11:27 AM
  • Actually what is your target schema? Please post your exact output schema. That can help us to suggest solution. the one you posted seems to be a trial based schema. Infact if you just have only one node at destination, you can after all direct link from source. so better post your exact output schema screen shot so that we can drive you towards right direction



    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Monday, April 28, 2014 11:38 AM
  • My output achema is as below

    <ns0:SpecificDestination xmlns:ns0="http://XSLTt.Schema2" />

    i am trying to expect a schema like this

    <ns0:SpecificDestination xmlns:ns0="http://XSLTt.Schema2">
      <Name>Name_0</Name>
    </ns0:SpecificDestination>

    is there any way we can get this using scripting functoid using XSLT?

    Tuesday, April 29, 2014 3:21 AM
  • i see that you have only one element "Name" in output schema under the root node record "SpecificDestination". There is no complexity here and after all you want you extract the name from source and map it to destination right? So you better just connect a link directly from source to destination node instead of going for scripting functiod or any external xslt. Ofcourse you can do the mapping with scripting functiod or xslt, but really i don't see any need of those functiods in your case as your mapping need is very simple. 


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Tuesday, April 29, 2014 4:30 AM
  • you are right, but i just want to learn XSLT so thought of doing this.

    Tuesday, April 29, 2014 5:47 AM
  • ok fine. But actually as suggested earlier, the xslt code should work.

    ok no problem if possible, you email me your zipped visual studio solution at ravindar.thati@zoho.com


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Tuesday, April 29, 2014 5:53 AM
  • i have sent you the solution.Please let me know if any

    Wednesday, April 30, 2014 4:53 PM
  • Hello Sujith,

    i got your email. i have fixed the issue and emailed it to you. Open the solution and check it.

    here is the correct script that you need to use, its quite easy

    <Nmae>
    <xsl:value-of select="/*[local-name()='Sampleschema' and namespace-uri()='http://xsltttttttttttttttt.Schema1']/*[local-name()='SampleDestination' and namespace-uri()='']/*[local-name()='Nmae' and namespace-uri()='']"/>
    </Nmae>

    also you have linked your scripting functiod to root node. you should connect it to element node for this case.


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Proposed as answer by Ravindar Thati Friday, May 2, 2014 5:42 AM
    • Marked as answer by Angie Xu Monday, May 5, 2014 1:31 AM
    Friday, May 2, 2014 5:38 AM