[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Version 2.0 Tips and Tricks

Subject: RE: Version 2.0 Tips and Tricks
From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx>
Date: Fri, 4 Apr 2008 17:43:21 +0530
RE:  Version 2.0 Tips and Tricks
well I got the error, just modified to the following. Thanks a ton.

<xsl:template match="article/meta/journalcode">
<xsl:element name="journalcode">
	<xsl:attribute name="dummy">
		<xsl:value-of select="string(.)"/>
	</xsl:attribute>
	<xsl:copy-of select="@*"/>
	</xsl:element>
</xsl:template>



-----Original Message-----
From: bryan rasmussen [mailto:rasmussen.bryan@xxxxxxxxx]
Sent: Friday, April 04, 2008 2:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Version 2.0 Tips and Tricks


to clarify, in the example I'm trying to copy an attribute after
creating a text node. The same thing happens with

 <xsl:template match="ref-govpub">
<xsl:copy>
<blah/>
<xsl:attribute name="bad">fail</xsl:attribute>
</xsl:copy>
</xsl:template>

and would be an error in 1.0 as well. However the example you gave so
far doesn't do this, so it is probably necessary to present full code
to know where the error is, unless you can debug yourself and find
where in your logic an attribute is being created after a child of an
element is added.

Cheers,
Bryan Rasmussen

On Fri, Apr 4, 2008 at 10:39 AM, bryan rasmussen
<rasmussen.bryan@xxxxxxxxx> wrote:
> in fact if I look in your transformation the point that seems most
>  likely to be causing it would be if  <xsl:apply-templates
>  mode="F-chic-auth-date"/> did something to call the copying template
>  on an attribute somewhere, for example with the following input:
>
>  <journals att="x">
>
>  <journalcode>CIJB</journalcode>
>  <ref-govpub>test
>  </ref-govpub>
>  </journals>
>
>  and the following stylesheet
>
>  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  version="2.0" xmlns:aid="example.org">
>  <xsl:output method="xml" encoding="utf-8"/>
>
>    <xsl:template match="@*|node()">
>   <xsl:copy>
>        <xsl:apply-templates select="@*|node()"/>
>   </xsl:copy>
>   </xsl:template>
>
>
>  <xsl:template match="ref-govpub">
>
>  <!-- journal Code check  -->
>
>   <xsl:if test="string(//journalcode)='CIJB'">
>   <xsl:copy>
>   <xsl:attribute name="aid:pstyle">ref</xsl:attribute>
>    <xsl:copy-of select="@*"/>
>    <xsl:apply-templates select="authorfield"/>
>   <xsl:apply-templates select="docpubtitle"/>
>   <xsl:apply-templates select="pubnum"/>
>   <xsl:apply-templates select="pubfield"/>
>  <xsl:if test="./chaptitle">
>  <char><xsl:text>, </xsl:text></char>
>    <xsl:apply-templates select="chaptitle"/>
>  </xsl:if>
>    <xsl:if test="./addinfo">
>    <xsl:apply-templates select="./addinfo"/>
>  </xsl:if>
>   <xsl:apply-templates mode="F-chic-auth-date"/>
>  <char><xsl:text>.</xsl:text></char>
>   </xsl:copy>
>   </xsl:if>
>  </xsl:template>
>
>  <xsl:template match="text()" mode="F-chic-auth-date">
>  hello
>
> <xsl:apply-templates select="/*/@*"/>
>  </xsl:template>
>  </xsl:stylesheet>
>
>  which of course gives the error that an attribute node cannot be
>  created after the child nodes of an element, because F-chic-auth-date
>  is running in the context of <ref-govpub> which is copied out,
>  followed by some other elements that are created and closed. After
>  which the mode is called, and the attribute is attempted to be added
>  at a place where an attribute cannot be added. Obviously the above is
>  just an example, but does it sound like anything you are doing in the
>  rest of your transformation?
>
>  Cheers,
>  Bryan Rasmussen
>
>
>
>
>  On Fri, Apr 4, 2008 at 10:32 AM, bryan rasmussen
>  <rasmussen.bryan@xxxxxxxxx> wrote:
>  > On Fri, Apr 4, 2008 at 10:05 AM, Pankaj Chaturvedi
>  >
>  > <pankaj.chaturvedi@xxxxxxxxx> wrote:
>  >  >
>  >
>  > >  why are you copying an attribute and then attempting to apply
>  >  >  templates on attributes or nodes below it?
>  >  >
>  >  >
>  >  >  Don't it means template copies input to output.
>  >
>  >
>  >  sure this:
>  >
>  >  <xsl:template match="@*">
>  >   <xsl:copy/>
>  >   </xsl:template>
>  >
>  >  is matching and copying an attribute
>  >
>  >  this is
>  >
>  >  <xsl:template match="@*">
>  >         <xsl:apply-templates select="@*"/>
>  >   </xsl:template>
>  >
>  >  matching an attribute and then applying templates on attributes  that
>  >  are children of that attribute, which is probably not gonna be too
>  >  successful.
>  >
>  >  thus this
>  >
>  >
>  >  <xsl:template match="@*|node()">
>  >   <xsl:copy>
>  >        <xsl:apply-templates select="@*|node()"/>
>  >   </xsl:copy>
>  >   </xsl:template>
>  >
>  >  is matching attributes and nodes
>  >  copying the matched, applying templates on any child attributes or
>  >  nodes of the matched attribute or node. This shouldn't be causing your
>  >  trouble, since it is allowed, it just always struck me as wasteful
>  >  when I see it.
>  >
>  >  Actually I can't see anything specifically in your code that is
>  >  causing the problem you mention.
>  >
>  >
>  >  Cheers,
>  >  Bryan Rasmussen


Confidentiality Notice:" This message and any attachment(s)
contained here are information that is confidential, proprietary to
IDS Infotech Ltd. and its customers.
Contents may be privileged or otherwise protected by law. The
information is solely intended for the individual or the entity it
is addressed to. If you are not the intended recipient of this
message, you are not authorized to read, forward, print, retain,
copy or disseminate this message or any part of it. If you have
received this e-mail in error, please notify the sender immediately
by return e-mail and delete it from your computer."

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.