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

Selection help

Subject: Selection help
From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Nov 2015 22:04:16 -0000
 Selection help
I have some XML similar to:
<root>
  <table name="SomeName">
    <column name="id" type="INTEGER" collate="" nullable="false" />
    <column name="foo_id" type="INTEGER" collate="" nullable="false" />
    <column name="bar" type="TEXT" collate="NOCASE" nullable="false" />
    <constraint type="FOREIGN" parentTable="OtherName" onDelete="CASCADE"
onUpdate="CASCADE">
     <childKey name="foo_id" />
     <parentKey name="id" />
    </constraint>
  </table>
</root>

For each "table" element, I am iterating through the "column[@name]" values
and
if a "constraint" element with a matching "childKey[@name]" is found, I need
to
perform some conditional logic.

My selector for foo is invalid, I need to select the parent of the matching
childKey
element, however I do not seem to even match the childKey element. Any idea
as to what I am missing?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:output method="text" />

  <xsl:template match=" /root">
    <xsl:result-document href="result.ext">
      <xsl:call-template name="result" />
  </xsl:template>

  <xsl:template name="result">

    <xsl:for-each select="table">
      <xsl:sort select="." />

      <xsl:variable name="this" select="." />

      <xsl:variable name="columns" as="xs:string *">
        <xsl:for-each select="column">
          <xsl:value-of select="@name" />
        </xsl:for-each>
      </xsl:variable>

      <xsl:for-each select="$columns">
        <xsl:variable name="foo"
select="$this/constraint[@type='FOREIGN']/childKey[@name='.']" />
        <!-- Test foo, output data if present. -->
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

Thanks,
jlc

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.