Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 21st, 2007, 04:01 AM
Friend of Wrox
Points: 718, Level: 10
Points: 718, Level: 10 Points: 718, Level: 10 Points: 718, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Element extraction

Hi,

Version 1.0

I need to identify (and extract) '0006509602/01' from the following code:

[u]XML</u>
Code:
<OrderLine LineNumber="1">
  <LineReference ReferenceType="Contract Number" AssignedBy="Buyer">0006509602/01</LineReference>
The OrderLine/LineNumber ('1') may be incremented throughout the full XML, which is why I have referred to the 'position()' in the follwing XSL. The XXXXXXX output, is the string that I need.

[u]XSL</u>
Code:
<xsl:template name="OrdLine">
  <xsl:for-each select="*//OrderLine/@LineNumber">
    <xsl:element name="OrderLine">
      <xsl:attribute name="LineNumber"><xsl:value-of select="$strLineNo"/></xsl:attribute>            
    <xsl:element name="LineReference">
      <xsl:attribute name="ReferenceType">Contract Number</xsl:attribute>
            <xsl:attribute name="AssignedBy">Buyer</xsl:attribute>
              <xsl:value-of select="XXXXXXX"/>            
        </xsl:element>
    </xsl:element>
  </xsl:for-each>    
</xsl:template>
I have tried various methods, but have been unsuccessful.

[u]Methods</u>
1.
Code:
.//OrderLine[@LineNumber='position()']/LineReference[@ReferenceType='Contract Number'][@AssignedBy='Buyer']
2.
Code:
.//OrderLine[@LineNumber='position()']/LineReference/[@AssignedBy='Buyer']
3.
Code:
.//OrderLine[@LineNumber='position()']//[@AssignedBy='Buyer']
[u]NOTE</u>
'LineReference' is one of several child-nodes of 'OrderLine'.

Thanks in advance,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
Reply With Quote
  #2 (permalink)  
Old March 21st, 2007, 04:14 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It's hard to say, your template matches OrdLine rather than OrderLine but that maybe a typo.
If you have a template matching OrderLine then to retrieve the desired string you need:
Code:
<xsl:value-of select="LineReference"/>
I'm not sure where the LineNumber attribute comes into play.
If this doesn't help you need to show the XML source and the desired output and the mapping between them.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old March 21st, 2007, 04:35 AM
Friend of Wrox
Points: 718, Level: 10
Points: 718, Level: 10 Points: 718, Level: 10 Points: 718, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi,

The 'OrdLine' template is fine. It is referenced and accessed (I confirmed this by debugging).

[u]XML</u>
Code:
<Order>
  <OrderLine LineNumber="1">
    <LineReference ReferenceType="Contract Number" AssignedBy="Buyer">0006509602/01</LineReference>
    <LineReference ReferenceType="Contract Number" AssignedBy="Supplier">ppersupref</LineReference>
    <ProductReference ReferenceType="Assigned By Buyer">496500</ProductReference>
    <ProductDescription Type="Defined by Buyer">REGULATOR 1</ProductDescription>
    <ProductValues>
      <Quantity QuantityType="Order Quantity" QuantityUOM="Unit">1000</Quantity>
      <UnitPrice PriceUOM="Unit">0.59</UnitPrice>
    </ProductValues>
  </OrderLine>
</Order>
The Value-of Select 'LineReference' also returns blank.



Neal

A Northern Soul
Reply With Quote
  #4 (permalink)  
Old March 21st, 2007, 04:53 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you need to show the full XML then as there's no OrdLine element showing so I can't tell what the correct path should be. Answering questions is easier if the poster follows the guidelines on the XSLT forum, where this question should really be :)

--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Unzip Zip Files using the Extraction Wizard southernsun VB How-To 0 December 6th, 2007 05:03 AM
XML data extraction Neal XSLT 2 March 21st, 2007 06:27 AM
XSLT subtree extraction dextermagnific XSLT 5 June 30th, 2006 05:00 AM
regular expression extraction paragraph radhakrishnan1976 General .NET 0 April 7th, 2006 04:35 AM
Ch. 6 - Term Extraction Example ddouglas BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 March 20th, 2006 05:11 AM



All times are GMT -4. The time now is 07:33 AM.


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