Subject: [xsl] Automatically copying an element's attributes and their values From: Mary McRae <marymcrae@xxxxxxxxxxxxx> Date: Sun, 07 Sep 2003 16:11:06 -0400 |
I would like to pass through attributes and their values without having to a) test to see if the attribute has a value specified, and b) explicitly output the value. This is the code I'm currently using: <xsl:template match="ns0:para" mode="blockindent"> <xsl:choose> <xsl:when test="@id"> <ns0:para id="{@id}"> <w:p> <w:pPr> <w:pStyle w:val="Blockindent"/> </w:pPr> <xsl:apply-templates mode="para"/> </w:p> </ns0:para> </xsl:when> <xsl:otherwise> <ns0:para> <w:p> <w:pPr> <w:pStyle w:val="Blockindent"/> </w:pPr> <xsl:apply-templates mode="para"/> </w:p> </ns0:para> </xsl:otherwise> </xsl:choose> </xsl:template> I tried using the code submitted by Mike Brown in Dave Pawson's FAQ: <ns0:para> <xsl:for-each select="@*"> <xsl:attribute name="name()"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> ... Remainder of template But using MSXML 3.0 in XMLSpy and Xselerator I got an error "This name may not contain the '(' character: name-->(<--); if I use the default XSLT processor in XMLSpy I don't get an error, but the attributes do not appear in my result file. The final transform will end up being performed using MSXML. It should also be noted that my source instance does not contain namespace prefixes (i.e. <para>asd;fljk adsflkjsda f</para> <para id="1234">adlfkj</para>) Thanks in advance, Mary XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Building a Manual with XM, S Woodside | Thread | [xsl] Automatically copying an elem, Mary McRae |
Re: [xsl] Loss of white space, Vasu Chakkera | Date | [xsl] Automatically copying an elem, Mary McRae |
Month |