2

Given the following content:

<div class="content">
  <div id="brian">
    <p>Hello my name is Alex</p>
    <p>My surname is Thomas</p>
    <p>My middle name is James</p>
    <p>true story...</p>
  </div>
</div>

And with the following in my theme:

<div id="dave" />

How so I replace #dave with the first paragraph? I've tried:

  • <replace content="//div[@class='content']/p" theme="div#dave" />
  • <replace content="//div[@class='content']/p[1]" theme="div#dave" />
  • <replace content="children://div[@class='content']/p" theme="meta#description" />

Neither worked... Please note that .content is buried fairly deep and can change position, so using its XPath is not an option. By xPath I mean /div/div/p[1] etc...

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
Alex
  • 8,875
  • 2
  • 27
  • 44

3 Answers3

0
<replace css:content=".content p:first-child" css:theme="#dave" />

Could be the solution ;) Vito

Vito
  • 1,201
  • 1
  • 10
  • 16
  • I made a mistake, take a look now to my solution – Vito Oct 04 '11 at 14:28
  • Note that the questionner is using Deliverance, not plone.app.theming/Diazo so the syntax is slightly different. css:content and css:theme is a Diazo thing not a Deliverance thing. – Laurence Rowe Oct 04 '11 at 16:39
0

For a pure xslt solution try this:

<replace content="//div[@class='content']/p[1]" theme="div#dave" />

edit:

i meant:

 <replace content="//div[@class='content']//p[1]" css:theme="div#dave" />

or

<replace content="//div[@class='content']/div/p[1]" css:theme="div#dave" />
Giacomo Spettoli
  • 4,476
  • 1
  • 16
  • 24
  • errrmmm guess you didnt fully read the question. I've tried this option. – Alex Oct 04 '11 at 14:26
  • grrr that still didn't work. unfortunately i can not use `` as it may not always be nested in the second `
    `. Thanks for trying.
    – Alex Oct 04 '11 at 14:33
0

The :first-child CSS selector should work -- so it would be something like

<replace content="p:first-child" theme="#dave" />

ejucovy
  • 907
  • 9
  • 10