[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

yet another XPath question

Subject: yet another XPath question
From: S Woodside <sbwoodside@xxxxxxxxx>
Date: Tue, 28 Jan 2003 13:40:59 -0500
xlandia
Seems like I'm trying to do "hard" things with Xpath these days. I wish there were a dedicated XPath mailing list or FAQ ... or is it that I'm the only one trying to use XPath in this way?

I'm passing an XPath back from an HTML form as a parameter to an XSLT stylesheet. I'm also passing a value to insert into that location, using, XUpdate (specifically XML::XUpdate::LibXML in perl). I'd like to then test the source document for the stylesheet, to see if that XPath is valid. OK, that's easy, I just test="/Big/Long/XPath" but wait, if it's /not/ present then I want to create sufficient nodes to insert the new element in that place. That means I want to test each location step in the XPath, one by one, from root to leaf, to see if it's there. If it isn't, I then create a new node for that location step, and then descend the rest of the XPath, creating nodes until I'm done and then I insert the value. Here's an example of what I want to have happen:

source XML docu:

<resume>
  <header>
    <name>
      <first>Simon</first>
    </name>
  </header>
</resume>

params from HTML forms into XSLT:
XPath: /resume/header/address/country
Value: XLandia

result XML docu:

<resume>
  <header>
    <name>
      <first>Simon</first>
    </name>
    <address>
      <country>
        XLandia
      </country>
    </address>
  </header>
</resume>

How do I do that? There doesn't seem to be any convenient way to break apart and analyse xpath steps in the spec, and I /don't/ want to start messing around with string conversions...

simon

---
www.simonwoodside.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.