On 30 November 2015 at 22:04, Joseph L. Casale
jcasale(_at_)activenetwerx(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
wrote:
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="." />
there is only one table so xsl:sort is doing nothing
<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>
That could more simply be written
<xsl:variable name="columns" select="column/string(@name)"/>
<xsl:for-each select="$columns">
<xsl:variable name="foo"
select="$this/constraint[@type='FOREIGN']/childKey[@name='.']" />
childKey[@name='.']"
selects childKey elements that have string value of their content
equal to their name attribute.
You presumably meant current() not .
<!-- Test foo, output data if present. -->
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks,
jlc
--~----------------------------------------------------------------
David
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--