Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 05:21 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Returning a value

Hi,

I need to retreive the 'Formatted Value' and 'Value' from the following xml:

Code:
<FormattedReportObjects>
  <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@INVOICE_NUMBER}">
    <ObjectName>INVOICENUMBER1</ObjectName>
    <FormattedValue>9</FormattedValue>
    <Value>9</Value>
  </FormattedReportObject>
</FormattedReportObjects>
I have tried to populate a variable using the example:
Code:
<xsl:variable name="strInvNo" select=".//*[@FieldName='{@INVOICE_NUMBER}']/FormattedValue"/>
But there is no value returned, please can you assist?

Thanks,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old October 12th, 2006, 05:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Given that your XML doesn't contain a namespace declaration for "xsi", I strongly suspect that you haven't shown us the whole of the XML, and my guess is that somewhere in the XML there is a default namespace declaration, which would mean that in your path expression, FormattedValue needs to be prefixed. That's extrapolating from very little evidence, but otherwise, what you've shown us seems correct.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 12th, 2006, 06:04 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi,

Sorry, I am using version 1.0 and the full path is:

Code:
<FormattedReport xmlns="urn:crystal-reports:schemas" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
  <FormattedAreaPair Level="0" Type="Report">
    <FormattedArea Type="Header">
      <FormattedSections>
        <FormattedSection SectionNumber="0">
          <FormattedReportObjects>
            <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@INVOICE_NUMBER}">
              <ObjectName>INVOICENUMBER1</ObjectName>
              <FormattedValue>9</FormattedValue>
              <Value>9</Value>
Neal

A Northern Soul
 
Old October 12th, 2006, 06:10 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

So I guessed right. The elements are in namespace xmlns="urn:crystal-reports:schemas" so you need to use a prefix on element names in the path expression. If in doubt google for "XSLT default namespace prefix".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 12th, 2006, 06:52 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

See links at http://p2p.wrox.com/topic.asp?TOPIC_ID=49630

--

Joe (Microsoft MVP - XML)
 
Old October 13th, 2006, 10:04 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi,

version 1.0

Thanks Mike for your assistance.

I have how managed to retreive data from my XML file. However, whereas the following will produces ALL node values:
Code:
.//*[@FieldName='{INVOICE_NUMBER}']/*
My original code returns no values:
Code:
.//*[@FieldName='{INVOICE_NUMBER}']/FormattedValue
Why is this?

Thanks in advance.

Neal

A Northern Soul
 
Old October 13th, 2006, 11:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

As explained previously, the FormattedValue element is in a namespace so it needs to be prefixed.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning Nothing from a constructor Imar Pro VB.NET 2002/2003 8 June 29th, 2012 02:00 PM
Returning a recordset John Pennington VB Databases Basics 8 August 18th, 2008 08:37 AM
help on returning records memewang Crystal Reports 0 April 14th, 2007 08:48 PM
BSTR * is not returning value sudharshansalvaji Visual C++ 1 October 16th, 2006 04:27 AM
Function not returning anything... goatboy Beginning PHP 2 December 1st, 2003 12:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.