[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [office] Extensible IDs
At 2003-07-31 19:57 +0200, Daniel Vogelheim wrote: >1) namespaced attribute values >The idea is to use namespace prefixes in attribute values. This is used >e.g. in XSD for datatypes. > >Example: If the chart namespace has been declared as >xmlns:chart=".../chart", then "chart:bar" or "chart:pie" would declare a >bar chart of pie chart from the chart namespace. If a default namespace >would have been used for the same namespace, i.e. xmlns=".../chart", then >"bar" and "pie" would refer to the same to chart types. To add your own, >you can declare xmlns:my=".../mine", and then use "mine:superchart" to >declare a your new 'superchart' chart type. >... >Could anyone come up with XSLT to compare two namespaced attributes, as >suggested in 1) ? Remember that the namespace axis contains nodes whose names are the prefix and values are the URI strings. I hope this helps. .............. Ken T:\ftemp>type daniel.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="http://www.mycharturi.org" version="1.0"> <xsl:template match="/"> <xsl:for-each select="/*/test"><xsl:text> </xsl:text> <xsl:value-of select="."/>: <xsl:text/> <xsl:for-each select="@val"> <xsl:choose> <xsl:when test=" contains( ., ':' ) and ../namespace::*[name(.)=substring-before(current(),':')]= document('')/*/namespace::chart and substring-after( ., ':' ) = 'this' "> <xsl:text>Yes: @val is in the chart namespace</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>No: @val is not in the chart namespace</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:for-each> <xsl:for-each select="/*/compare"><xsl:text> </xsl:text> <xsl:value-of select="."/>: <xsl:text/> <xsl:choose> <xsl:when test="contains(@val1,':') and contains(@val2,':') and namespace::*[name(.)=substring-before(current()/@val1,':')]= namespace::*[name(.)=substring-before(current()/@val2,':')] and substring-after(@val1,':') = substring-after(@val2,':')"> <xsl:text>Yes: attributes are the same qualified value</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>No: attributes are not the same qualified value</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet> T:\ftemp>type daniel.xml <?xml version="1.0" encoding="iso-8859-1"?> <tests xmlns:look="http://www.mycharturi.org" xmlns:lookagain="http://www.mycharturi.org" xmlns:other="http://www.otheruri.org"> <test val="look:this">First pre-determined test</test> <test val="this">Second pre-determined test</test> <test val="other:this">Third pre-determined test</test> <test val="lookagain:this">Fourth pre-determined test</test> <compare val1="look:this" val2="other:this">First comp test</compare> <compare val1="look:this" val2="lookagain:this">Second comp test</compare> <compare val1="look:this" val2="lookagain:that">Third comp test</compare> </tests> T:\ftemp>saxon daniel.xml daniel.xsl <?xml version="1.0" encoding="utf-8"?> First pre-determined test: Yes: @val is in the chart namespace Second pre-determined test: No: @val is not in the chart namespace Third pre-determined test: No: @val is not in the chart namespace Fourth pre-determined test: Yes: @val is in the chart namespace First comp test: No: attributes are not the same qualified value Second comp test: Yes: attributes are the same qualified value Third comp test: No: attributes are not the same qualified value T:\ftemp> -- Upcoming hands-on courses: in-house corporate training available; North America public: XSLT/XPath Aug 12, 2003 G. Ken Holman mailto:gkholman@CraneSoftwrights.com Crane Softwrights Ltd. http://www.CraneSoftwrights.com/o/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/o/bc
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]