xsl-list
[Top] [All Lists]

Re: XSLT processor and substring-after

2005-04-13 13:26:59
Sorry, but I've not used Perl's XML/XSL facilities. Perhaps one of the 
list's other members has, though.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)



"N Zhou" <zhou_naijun(_at_)hotmail(_dot_)com> 
04/13/2005 03:05 PM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com


To
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
cc

Subject
Re: [xsl] XSLT processor and substring-after






Hi Jay,

Thank you very much! I think the path is correct, but my processor does 
not 
support XPath well. I'm usingXML::XSLT with a depedency on XML::Parser not 

on XPath. Do you know Perl XSLT module supporting XPath 1.0 or higher? I 
know Saxon but I prefer CGI script.

The full source data:

<?xml version="1.0" encoding="ISO-8859-1" ?>
     <wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"; 
xmlns:gml="http://www.opengis.net/gml";>
        <gml:boundedBy>
           <gml:Box srsName="epsg:4326">
              <gml:coordinates>-89,43 -95,43</gml:coordinates>
           </gml:Box>
       </gml:boundedBy>
</wfs:FeatureCollection>

My XSL is:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:wfs="http://www.opengis.net/wfs"; 
xmlns:gml="http://www.opengis.net/gml"; 
xmlns:b="http://www.opengis.net/examples"; 
xmlns="http://www.fgdc.gov/fgdc/gc"; xmlns:saxon="http://icl.com/saxon";>
<xsl:output method="xml" standalone="yes" omit-xml-declaration="no" 
encoding="ISO-8859-1"/>

<xsl:template match="/">
<Points>
   <gml:boundedBy>
     <gml:Envelope>
        <xsl:variable name="coords1" 
select="wfs:FeatureCollection/gml:boundedBy/gml:Box/gml:coordinates"/>
            <gml:lowerCorner>
                 <xsl:value-of select="substring-before($coords1,' ')"/>
            </gml:lowerCorner>
            <gml:upperCorner>
                 <xsl:value-of select="substring-after($coords1,' ')"/>
            </gml:upperCorner>
      </gml:Envelope>
    </gml:boundedBy>
</Points>
</xsl:template>
</xsl:stylesheet>

Thanks again.

N Zhou

From: JBryant(_at_)s-s-t(_dot_)com
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] XSLT processor and substring-after
Date: Wed, 13 Apr 2005 14:48:00 -0500

With the following source XML (yours with the namespace removed for
simplicity's sake):

<?xml version="1.0" encoding="UTF-8"?>
<boundedBy>
  <Box>
    <coordinates>89,43 90,43.5</coordinates>
  </Box>
</boundedBy>

I got the following stylesheet to work with Saxon 8:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:template match="/">
    <xsl:variable name="coords1" select="/boundedBy/Box/coordinates"/>
    <out>
      <lowerCorner>
        <xsl:value-of select="substring-before($coords1, ' ')"/>
      </lowerCorner>
      <upperCorner>
        <xsl:value-of select="substring-after($coords1,' ')"/>
      </upperCorner>
    </out>
  </xsl:template>

</xsl:stylesheet>

To produce the following output:

<?xml version="1.0" encoding="UTF-8"?>
<out>
  <lowerCorner>89,43</lowerCorner>
  <upperCorner>90,43.5</upperCorner>
</out>

My guess is that you've not properly specified the path in the select 
part
of the variable or that your processor has a problem. Perhaps you should
shows us more of the source document, so that we can help you develop a
better path or help you determine that the problem is your processor.

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)





"N Zhou" <zhou_naijun(_at_)hotmail(_dot_)com>
04/13/2005 01:57 PM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com


To
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
cc

Subject
[xsl] XSLT processor and substring-after






Hi,

I'm using XML::XSLT Perl module to transform XML data:
<gml:boundedBy>
  <gml:Box>
      <gml:coordinates>89,43 90,43.5</gml:coordinates>
</gml:Box>
</gml:boundedBy>

I want to split the 89,42 90, 43.5 to two substrings as :
<gml:boundedBy>
  <gml:Envelope>
      <gml:lowerCorner>89,43</gml:lowerCorner>
      <gml:upperCorner>90,43.5</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>

I tried substring-after but didn't get results (XML::XSLT returned 
blank):
        <xsl:variable name="coords1"
select="gml:boundedBy/gml:Box/gml:coordinates"/>
        <gml:lowerCorner>
           <xsl:value-of select="substring-before($coords1, ' ')"/>
        </gml:lowerCorner>
        <gml:upperCorner>
            <xsl:value-of select="substring-after($coords1,' ')"/>
        </gml:upperCorner>

Could anyone tell me why I cannot split the string: are there errors in 
my

XSL; or, the module XML::XSLT does not support substring-after (it uses
XPath1.3)? Anyone can recommend me another Perl module of XSLT processor?

Thank you very much!

n zhou



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--