cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Puerto <jpue...@gmail.com>
Subject Re: Dom Transformer
Date Fri, 15 Mar 2013 19:40:24 GMT
2013/3/15 Mansour Al Akeel <mansour.alakeel@gmail.com>

> I have tags with id's like:
>
> <some-section-tag id='109876_n00069" .... >
>
> And those ids are used for links inside the document. They are linked
> from different sections.
> I like to transform the links and the ids to something that makes sense.
> Like,
>
> <xref href="the-section-title-with-dashes-only" > My Link Label</xref>
>
> And
>
> The anchor
>
> <some-section-tag id='the-section-title-with-dashes-only" .... >
>
> I think this can be done is Stax, xslt or Sax, however, I am trying to
> do it in a clean way without any hacks.
>
> Do you have any suggestion ??
>

XSLT sample:

You can add the following transformation to oyur pipeline sitemap.xmap:

<map:transform src="resources/xslt/uuid2title.xsl"/>

And create an xslt file that maches the elements you want to change
uuid2title.xsl

<xsl:template match="some-section-tag/@id">
  <xsl:attribute name="id">
    <xsl:value-of select="replace([your tile node xpath], " ", "")"/>
  </xsl:attribute>
</xsl:template>

I hope that helps, I've not tested it. With SAX and StAX it's similar but
written in java, you have to locate the element you are looking for and
replace the attribute with the new one. Most times XSLT is enough, SAX and
StAX is used if you have to do some business logic.

DOM is not good idea because is not event based and Cocoon pipeline is
based on XML events so to work with DOM you have to do double work,
transform to DOM and generate SAX or StAX events later to hook the pipeline.

Salu2.


>
>
>
> On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 <gelo1234@gmail.com> wrote:
> > The question is WHY? you want DOM transformation in Cocoon environment ?
> >
> > Greetings,
> > -Greg
> >
> >
> > 2013/3/15 Mansour Al Akeel <mansour.alakeel@gmail.com>
> >>
> >> I know this may sound strange, but I like to create a transformation
> with
> >> DOM.
> >> I was able to see Stax and Sax transformation. I was not able to see
> >> one for DOM.
> >>
> >> Any advice ?? Examples ??
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Mime
View raw message