in reply to xml::xslt xpath question

<xsl:value-of select="/PLMXML/Form@subType='Part Revision Master']/UserData/UserValue[@title='cage_code']/@value"/>

Missing [, the Form doesn't have a UserData child, and I can't verify from what you've shown that the Form has the right ancestry.

<xsl:strip-space elements="*"/><xsl:value-of select="/PLMXML/Form@subType='PartRevisionMaster']/UserData/UserValue[@title='cage_code']/@value"/>

Missing [, the Form doesn't have a UserData child, and I can't verify from what you've shown that the Form has the right ancestry.

<xsl:value-of select="/PLMXML/Form@subType='Part#x20Revision#x20Master']/UserData/UserValue[@title='cage_code']/@value"/>

Missing [, the Form doesn't have a UserData child, and I can't verify from what you've shown that the Form has the right ancestry.

I can't comment the later snippets since I know XPath, not XSLT.

Replies are listed 'Best First'.
Re^2: xml::xslt xpath question
by Anonymous Monk on Jul 06, 2009 at 19:40 UTC
    I'll add the full xml below but my biggest challenge is in finding the xpath methods that are available in Perl to select a node by its attributute value - when the attribute value includes space.

      Simplified XML:

      <?xml version="1.0" encoding="utf-8"?> <PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema"> <Form subType="Part Revision Master"> <UserData> <UserValue title="cage_code" value="98747"/> </UserData> </Form> </PLMXML>

      You keep mentioning spaces, but I don't see why that would be a problem.

      Did you try fixing the the missing "[" I mentioned? If the first snippet doesn't work with the missing "[ fixed, I suspect a namespace problem. I don't know how XSLT deals with namespaces, so I can't help you there.

      Outside of XSLT, your XPath would be wrong since it references elements in the null namespace while they are in the http://www.plmxml.org/Schemas/PLMXMLSchema namespace.

        It seems to have a problem handling spaces because when I use the following xpath statement
        <xsl:value-of select="/PLMXML/Form[@subType='Part Revision + Master']/UserData/UserValue[@title='cage_code']/@value"/>
        I get the following error
        get-node-from-path: Don't know what to do with path [attribute::subTyp +e='Part Re vision Master']/UserData/UserValue[attribute::title='cage_code']/attri +bute::valu e !!!
        But if I use the following xpath statement I don't catch an error.
        <xsl:value-of select="/PLMXML/Form[@id='id24']/UserData/Us +erValue[@title='cage_code']/@value"/>