Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
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 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 March 21st, 2007, 04:01 AM
Friend of Wrox
 
Join Date: Jan 2006
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
 
Old March 21st, 2007, 04:14 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
Old March 21st, 2007, 04:35 AM
Friend of Wrox
 
Join Date: Jan 2006
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
 
Old March 21st, 2007, 04:53 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)





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





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