Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT Namespaces

Status
Not open for further replies.

lbrooks

IS-IT--Management
Jan 20, 2004
42
US
What would cause a XML schema definition to prevent how elements display. I have a XSLT file and a XML file that point to a stadnard schema for a given industry. If I remove the schema information from the XML, my information displays just fine within a browser. But if I include the schema information, every single element displays within the browser. I have included the XSLT and a sample of the XML. Any suggestion would be grealty appreacited.

XSLT

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:template match="//BatchInformation/MasterRecipe">
<xsl:apply-templates select="RecipeElement"/>
</xsl:template>
<xsl:template match="RecipeElement">
<xsl:for-each select="Header/ModificationLog">
<xsl:value-of select="ModifiedDate"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

XML

<?xml version="1.0" encoding="UTF-8"?>
<BatchInformation xmlns=" xmlns:xsi=" xsi:schemaLocation="BatchML-V02.xsd">
<MasterRecipe>
<RecipeElement>
<Header>
<ModificationLog>
<ModifiedDate>String</ModifiedDate>
<Description>String</Description>
<Description>String</Description>
<Author>String</Author>
<Any/>
<Any/>
</ModificationLog>
<ModificationLog>
<ModifiedDate>String</ModifiedDate>
<Description>String</Description>
<Description>String</Description>
<Author>String</Author>
<Any/>
<Any/>
</ModificationLog>
</Header>
</RecipeElement>
</MasterRecipe>
</BatchInformation>
 
You do have a namespace problem, but perhaps not the one you think. Try this XSLT:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"             
	xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
	xmlns:r="[URL unfurl="true"]http://www.wbf.org/xml/BatchML-V02">[/URL]
<xsl:output method="html"/>
<xsl:template match="//r:BatchInformation/r:MasterRecipe">
<xsl:apply-templates select="r:RecipeElement"/>
</xsl:template>
<xsl:template match="r:RecipeElement">
       <xsl:for-each select="r:Header/r:ModificationLog">
 <xsl:value-of select="r:ModifiedDate"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

This is addressed in this FAQ: faq426-1188

Tom Morrison
 
Thank you! That seemed to solve my problem.
 
I think I spoke to soon. Actually I am right back to the originally problem. All of the children for a given element are shown instead of the one I specified in the XSLT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top