in reply to Re^3: xml::xslt xpath question
in thread xml::xslt xpath question

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"/>

Replies are listed 'Best First'.
Re^5: xml::xslt xpath question (solution)
by ikegami (Patriarch) on Jul 06, 2009 at 20:52 UTC
    And I found the bug:
    elsif ( $path =~ s/^\/(child\:\:|)(\*|[\w\.\:\-]+)\[(\S+?)\]// ) ^^^^
    Switching that line to following should do the trick:
    elsif ( $path =~ s/^\/(child\:\:|)(\*|[\w\.\:\-]+)\[(.+?)\]//s )

    Reported.

      I don't understand. Where should I apply this to fix my problem? Thanks for your help!
        In XML/XSLT.pm. You can find the full path using the following:
        perl -e'use XML::XSLT; print $INC{"XML/XSLT.pm"}'

        Update: Or

        perldoc -l XML::XSLT
Re^5: xml::xslt xpath question (problem)
by ikegami (Patriarch) on Jul 06, 2009 at 20:40 UTC
    I can replicate your problem:

    foo.pl:

    #!/usr/bin/perl use strict; use warnings; use XML::XSLT qw( ); use Object::Destroyer qw( ); my $xslt = Object::Destroyer->new( XML::XSLT->new('foo.xslt', warnings => 1), 'dispose', ); $xslt->transform('foo.xml'); print $xslt->toString;

    foo.xml:

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

    foo.xslt:

    <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr +ansform"> <xsl:template match="/"> <xsl:value-of select="/PLMXML/Form[@subType='Part Revision Master']/Us +erData/UserValue[@title='cage_code']/@value"/> </xsl:template> </xsl:stylesheet>

    Also tried:

    Works: "/PLMXML/Form[@id='id24']/UserData/UserValue[@title='cag +e_code']/@value" Doesn't work: "/PLMXML/Form[@subType='Part Revision Master']" Doesn't work: "/PLMXML/Form[@subType=&quot;Part Revision Master&quot;] +/UserData/UserValue[@title='cage_code']/@value"

    (This should have been in your original post)