Select element value based on attribute values in XML.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhijeetraje
    New Member
    • Mar 2009
    • 2

    Select element value based on attribute values in XML.

    I am applying XSLT to WSDL to generate html pages.

    now, as WSDL is not having comprehensive details, i am adding XML documentation (.NET) as well in XSLT.
    like this..
    Code:
    <xsl:variable name="ddoc" select="document('CustomerCare.ManageMeterReads.ServiceContracts.xml')" />
    Here is the XML documentation.. ..
    Code:
    <?xml version="1.0"?>
    <doc>
    <assembly>
    <name>CustomerCare.ManageMeterReads.ServiceContracts</name>
    </assembly>
    <members>
    <member name="T:abc.pqr.test.CustomerCare.ManageMeterReads.ServiceContracts.CommonEntities.EmployeeID">
    <summary>
    Holds the configuration details for each Service.
    </summary>
    </member>
    </members>
    </doc>

    WSDL is having element types e.g. EmployeeID ( i am able to extract the element types from XSDL, storing it in $type-local-name) however the description of that element is in above xml. my requirement is to get the "summary" element from above xml based on the member/name attribute.

    WSDL just contain "EmployeeID " not full value "T:abc.pqr.test .CustomerCare.M anageMeterReads .ServiceContrac ts.CommonEntiti es.EmployeeID".

    I tried this... but not working...
    Code:
    <xsl:value-of select="$ddoc/doc/members/member[contains($ddoc/doc/members/member/@name,$type-local-name)]/summary"/>
    Last edited by Dormilich; Mar 24 '09, 11:56 AM. Reason: added [code] tags
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Look for the name attribute at the node you currently are condition testing.
    [contains(@name, $type-local-name)]

    Comment

    • abhijeetraje
      New Member
      • Mar 2009
      • 2

      #3
      Select element value based on attribute values in XML

      I tried this...
      <xsl:value-of select="$ddoc/doc/members/member[@name='contains (@name,$type-local-name']/summary"/>

      however its not showing any results.

      i want to extract summary element in $ddoc where attribute "name" is having value that contains $type-local-name'

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I think jkmyoung was rather proposing this
        Code:
        <xsl:value-of select="$ddoc/doc/members/member[contains(@name,$type-local-name)]/summary"/>

        Comment

        Working...