Subject: RE: [xsl] include, import trouble From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Sun, 8 Jan 2006 23:29:59 -0000 |
You're doing some strange things with namespaces here. The prefix "xsi" is usually bound to the namespace "http://www.w3.org/2001/XMLSchema-instance". It's not wrong to bind it to a different namespace, but it's likely to confuse your readers. The element "Single" is in namespace "schema1.xsd" (again, not a particularly good choice for a namespace URI, because relative URIs are deprecated; but not incorrect). Stylesheet1 selects element Single in namespace "schema1.xsd" successfully, using the "xsi" prefix to access it. But stylesheet2 attempts to access an element with local name "Single" in namespace "schema2.xsd" - and there isn't one. The element is in namespace "schema1.xsd". Generally, if you want to avoid confusion, it's good practice to use prefixes consistently - choose a prefix that gives a clue about the namespace it's bound to, e.g. s1 to refer to schema1 and s2 to refer to schema2. Otherwise you can spend a long time staring at your code wondering why it doesn't do what you expect. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: target [mailto:target@xxxxxxxxx] > Sent: 08 January 2006 17:19 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] include, import trouble > > hi, i have a problem with importing stylesheet or including templates. > no output is shown when i transform either with firefox or with php5. > > I have a "xml1" datafile defined by a "schema1" an a "stylesheet1" to > display it as HTML. this works all fine and is valid. > but when I created another "schema2" that basically defines > a loop of > the original entitity, and therefore uses the "schema1" > namespaces and > also created a valid "xml2" (defined only by "schema2") with many > entities, Im not able to make a "stylesheet2" that uses the > "stylesheet1" by importing it. > Im playing around but now I need help. > Some Code: > _____________________________________ > "stylesheet1" which works fine > <?xml version="1.0" encoding="iso-8859-1"?> > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xsi="schema1.xsd" exclude-result-prefixes="xsi" > version="1.0" > > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match="xsi:Single"> > ... > </xsl:template> > </xsl:stylesheet> > _____________________________________________ > the "schema2" which also works fine and successfully uses the > "schema1" > ... > xmlns:paps="schema2.xsd" > xmlns:pap="schema1.xsd" > ... > <import namespace="schema1.xsd"/> > > <element name="Multible" type="paps:typeMulti"/> > <complexType name="typeMulti" > > <sequence minOccurs="1" maxOccurs="unbounded"> > <element ref="pap:Single" /> > </sequence> > </complexType> > </schema> > ____________________________ > "stylesheet2" which wouldnt do what it should > <?xml version="1.0" encoding="iso-8859-1"?> > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xsi="schema2.xsd" > version="1.0" > > > > <xsl:include href="stylesheet1.xsl"/> > > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="xsi:Multible"> > <xsl:apply-templates select="xsi:Single"/> > </xsl:template> > > </xsl:stylesheet> > _______________________________________ > whatever I try importing and including "stylesheet1", it > shows nothing > (no error). seems like a simple thing - what is wrong? > when I copy only the template for xsi:Single as it is from > "styleshee1" > to add it manually to "stylesheet2" it works perfectly. > Is it because the element names are not recognized by the > "stylesheet2" > because the are definde in different schemas? > > thanks for help.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] include, import trouble, Florent Georges | Thread | Re: [xsl] include, import trouble, target |
[xsl] Needing to use XML with Exce, nellsousa | Date | [xsl] Needing to use XML with Excel, nellsousa |
Month |