Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - xsl name spaces - filtering >Thread Next - Re: xsl name spaces - filtering Re: xsl name spaces - filteringTo: NULL Date: 3/3/2009 5:41:00 PM vanSkier wrote: > I'm relatively new to xsl and am floundering when trying to access the > ID and TableID values from the xml below. > > Would the multiple names spaces in the Database node cause any > problems? > <Create xmlns="http://schemas.microsoft.com/analysisservices/2003/ > engine"> The Create element has a default namespace declaration that applies to the Create element and all its descendant elements so in your XSLT stylesheet you need to bind a prefix to that namespace and use that prefix in XPath expressions and match patterns to a select/match elements. See below. > <ObjectDefinition> > <Database xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <ID>Insight_Budget</ID> > <Dimensions> > <Dimension> > <ID>Tbl Dim Division</ID> > <Name>Division</Name> > <Attributes> > <Attribute> > <ID>Level0 Name</ID> > <Name>Division Level0 Name</Name> > <Usage>Key</Usage> > <EstimatedCount>39</EstimatedCount> > <KeyColumns> > <KeyColumn> > <DataType>WChar</DataType> > <DataSize>80</DataSize> > <Source xsi:type="ColumnBinding"> > <TableID>dbo_tblDimDivision</TableID> > <ColumnID>Level0_Name</ColumnID> > </Source> > </KeyColumn> > </KeyColumns> > </Attribute> > </Attributes> > </Dimension> > </Dimensions> > </Database> > </ObjectDefinition> > </Create> > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ > Transform" xmlns:xlink_01="http://schemas.microsoft.com/ > analysisservices/2003/engine" xmlns:xlink_02="http://www.w3.org/2001/ > XMLSchema" > So you have correctly bound a prefix ('xlink_01') to the default namespace but > <xsl:template match="/"> > > <HTML> > <BODY> > <xsl:apply-templates select="//xlink_01:Create"/> > <xsl:apply-templates select="//xlink_01:Create/ObjectDefinition/ > Database/Dimensions/Dimension/ID"/> here you fail to apply that prefix consistently to all elements e.g. <xsl:apply-templates select="/xlink_01:Create/xlink_01:ObjectDefinition/xlink_01:Database/xlink_01:Dimensions/xlink_01:Dimension/xlink_01:ID"/> > <xsl:apply-templates select="//xlink_01:Create/ObjectDefinition/ > xlink_02:Database/Dimensions/Dimension/ID"/> > <xsl:apply-templates select="//Create/ObjectDefinition/Database/ > Dimensions/Dimension/ID"/> > <xsl:apply-templates select="ID"/> > <xsl:apply-templates select="//xlink_01:Create/ObjectDefinition/ > Database/Dimensions/Dimension/Attributes/Attribute/KeyColumns/ > KeyColumn/Source/TableID"/> Make the same changes for all those XPath expressions above. > </BODY> > </HTML> > </xsl:template> > > > <xsl:template match="//xlink_01:Create"> <xsl:template match="xlink_01:Create"> suffices, but that is only a minor issue not related to the other problem explained above. > <B> > <xsl:text>This works: </xsl:text> > <xsl:value-of select="local-name()" /> > </B> > </xsl:template> > > > <xsl:template match="ID"> You need <xsl:template match="xlink_01:ID"> > <B> > <xsl:value-of select="local-name()" /> > </B> > </xsl:template> > > > <xsl:template match="TableID"> and <xsl:template match="xlink_01:TableID"> > <B><xsl:value-of select="local-name()" /></B> > </xsl:template> > > > </xsl:stylesheet> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
