Subject: fun with namespaces From: "Dave Pawson" <dave.pawson@xxxxxxxxxx> Date: Wed, 8 Mar 2000 21:55:02 -0000 |
Well, I tried it. I think I understand it. A clearer example of usage of exclude-result-prefixes="" would help. Questions: 1. why does xt complain when it occurs after the namespace declarations. (If the answer is RTFM please ignore) Points of note. No matter that I don't want them in the output, if xt deems it necessary to have them to identify content in the output tree, it puts them there. The only affected items are literal content from the stylesheet. I'd be obliged if someone could tell me if the XML source is 'correct' in its use of namespaces. XT eventually stopped complaining after I tried various combinations. I didn't try using a namespace on an attribute, in combination with a namespace on the element... my brain was hurting by then :-) Have fun. DaveP <?xml version="1.0" ?> <!DOCTYPE ns1:ns-test [ <!ELEMENT ns1:ns-test (block)+> <!ATTLIST ns-test xmlns:ns1 CDATA #FIXED "http://ns1.com" > <!ELEMENT block (para)+> <!ATTLIST block xmlns:ns2 CDATA #FIXED "http://ns2.com" > <!ELEMENT para (#PCDATA)> <!ATTLIST para id ID #IMPLIED another CDATA #IMPLIED>]> <!-- so top level belongs to namespace ns1 --> <ns1:ns-test xmlns:ns1= "http://ns1.com"> <block> <para>Para in block 1, main document namespace </para> </block> <ns2:block xmlns:ns2="http://ns2.com"> <para>Para in block 2</para> </ns2:block> <ns3:block xmlns:ns3="http://ns3.com"> <para>Para in block 3</para> </ns3:block> </ns1:ns-test> <xsl:stylesheet version="1.0" exclude-result-prefixes="ns1 ns2 long-namespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns-test="http://ns1.com" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" xmlns:long-namespace="http://ns3.com" > <!-- Try removing some or all of the list of namespaces in exclude-result-prefixes --> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="ns1:ns-test"> <xsl:apply-templates/> </xsl:template> <xsl:template match="ns2:block"> <comment>ns2 namespace selected</comment> <xsl:copy> <xsl:value-of select="para"/> </xsl:copy> </xsl:template> <xsl:template match="long-namespace:block"> <comment>long-namespace namespace Template used</comment> <xsl:copy> <comment>long-namespace namespace selected</comment> <xsl:value-of select="long-namespace:para"/> </xsl:copy> <xsl:copy> <xsl:value-of select="para"/> </xsl:copy> <para>Some literal content introduced from the stylesheet</para> </xsl:template> <xsl:template match="block"><!-- Which namespace is this in then? --> <comment>No namespace Template used</comment> <xsl:copy> <xsl:value-of select="para"/> </xsl:copy> </xsl:template> <xsl:template match="*"/> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
custom outputhandlers in xt (e.g. f, Tom Myers | Thread | Re: fun with namespaces, David Carlisle |
Re: xml & forms revisited, Eric van der Vlist | Date | Re: conditional counting of element, Michel CASABIANCA |
Month |