 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 17th, 2011, 04:54 AM
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
query for Days
Hello, im totaly new in XML and XSL and now i have to customize a XSL file and i hope you can help me.
We are filling different InDesign documents with ONE XML and different XSL files (for example different areas) and now we got a new Element in our XML calls:
<validation></validation> and it shows for which days of a week the filling is.
Normaly we have have no query for that
but now we got a new Document for a shorter week (<validation>Mi,Do,Fr,Sa</validation>).
Can you help me? I have absolute no idea how to get this.
Here an example code from our XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Root createAt="16_8_2011" week="36" year="2011">
<ausgabe>Gültig vom 05.09.
bis 10.09.2011</ausgabe>
<werbegruppe id="vSIrogAAATBlMm3WkZ0">
<vertriebsschiene id="1" name="Schiene1">
<seite/>
<a3>false</a3>
<a4>false</a4>
<a5>true</a5>
<pos>false</pos>
<streichpreis>10.99</streichpreis>
<prozentangabe>18</prozentangabe>
</vertriebsschiene>
<vertriebsschiene id="2" name="Schiene2">
<seite/>
<streichpreis>10.99</streichpreis>
<prozentangabe>18</prozentangabe>
</vertriebsschiene>
<vertriebsschiene id="3" name="Schiene3">
<seite/>
<streichpreis>10.99</streichpreis>
<prozentangabe>18</prozentangabe>
</vertriebsschiene>
<orderNr>6</orderNr>
<wp>7.15</wp>
<lvp>8.99</lvp>
<kennzeichen id="3">Ost/West</kennzeichen>
<ekBereich>607</ekBereich>
<vaHinweis>ohne handzettelabbildung</vaHinweis>
<rsUeber>false</rsUeber>
<headline1>ArtikelHead</headline1>
<headline2>ArtikelSubhead</headline2>
<content>ArtikelContent</content>
<grammage>1000 g Packung</grammage>
<vergleichsPe>0.0</vergleichsPe>
<inhaltsMe/>
<grundpreis/>
<gueltigkeit>Mo,Di,Mi,Do,Fr,Sa</gueltigkeit>
<logo1 href=""/>
<logo2 href=""/>
<logo3 href=""/>
<leitartikel-bild href="\\test\test1.eps"/>
<!---->
</werbegruppe>
And here an example code from the existic XSL File:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="vs" select="'Schiene2'"/>
<xsl:variable name="anzahlSeiten" select="15"/>
<xsl:key name="sites" match="Root/werbegruppe/vertriebsschiene[@name=$vs]" use="seite"/>
<xsl:template match="/">
<xsl:element name="Root">
<xsl:element name="ausgabe">
<xsl:value-of select="normalize-space(Root/ausgabe)"/>
</xsl:element>
<xsl:if test="$vs='Schiene1'">
<xsl:element name="Musterseite1">
<xsl:text disable-output-escaping="no">_KW</xsl:text>
<xsl:value-of select="Root/@week"/>
</xsl:element>
<xsl:element name="Musterseite2">
<xsl:text disable-output-escaping="no">_KW</xsl:text>
<xsl:value-of select="Root/@week"/>
</xsl:element>
<xsl:element name="Musterseite3">
<xsl:text disable-output-escaping="no">_KW</xsl:text>
<xsl:value-of select="Root/@week"/>
</xsl:element>
</xsl:if>
<xsl:call-template name="fktCall">
<xsl:with-param name="von" select="1"/>
<xsl:with-param name="myNode" select="."/>
</xsl:call-template>
</xsl:element>
</xsl:template>
Greetings
|
|

August 17th, 2011, 05:26 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
You don't give any clue at all what you are expecting the output to look like. Perhaps show us what your current XML output looks like and then show us what you want the new XML output to look like.
Last edited by samjudson; August 17th, 2011 at 05:34 AM..
|
|

August 17th, 2011, 07:55 AM
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hello samjudson,
i will try to explain it a little bit better.
The normal output from the XML is still working, but now i want only a few informations from the XML, not all of them.
Now i want only the the products (<werbegruppe></werbegruppe>) where the value of the validation element (<gueltigkeit></gueltigkeit>) is "Mi,Do,Fr,Sa"
i dont want the products where the value is "Mo, Di, Mi,Do,Fr,Sa" (days of the week)
So that you can fill two different documents with the same XML and each of this document has a different content one for the hole week and one only for a short week.
i hope that was a bit better.
If you need more informations please ask.
|
|

August 17th, 2011, 09:15 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Still not really clear what you mean. I don't see anything in your input XML with a value of 'Mi,Do,Fr,Sa'.
If however you want to select a product with that element then the xpath would look something like this:
Code:
werbegruppe[gueltigkeit='Mi,Do,Fr,Sa']
I don't know if that helps.
|
|

August 18th, 2011, 05:11 AM
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hello Samjudson,
at the moment you see the element <gueltigkeit>Mo,Di,Mi,Do,Fr,Sa</gueltigkeit>
but that ist only one example from the XML. We have a lot of elements like <werbegruppe> and some of them have <gueltigkeit>Mo,Di,Mi,Do,Fr,Sa</gueltigkeit> and other ones have <gueltigkeit>Mi,Do,Fr,Sa</gueltigkeit>.
How can i tell my XSL that i want only the <werbegruppe> elements where is <gueltigkeit>Mi,Do,Fr,Sa</gueltigkeit> ?
That would be a second query the first one is:
Code:
<xsl:key name="sites" match="Root/werbegruppe/vertriebsschiene[@name=$vs]" use="seite"/>
Can i include a secend one with <gueltigkeit>?
I hope now it is a little bit more cleare what i want.
And by the way, thak you for helping me and all your patience!
|
|

August 18th, 2011, 09:39 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Well somewhere in your XSLT file there will either be a template that matches against "werbegruppe" or a xsl:for-each select statement that selected all "werbegruppe" elements.
You simply need to change that match or select statement for the one I posted above.
You haven't posted much of your XSLT above so it is impossible to give you more than some guidelines to follow.
|
|

August 19th, 2011, 01:58 AM
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
You are right and im sorry for that, i thought it was the important part of the XML, but as i see now, it is impossible to understand my XSL only with that short code.
I figured it out now.
Code:
<xsl:key name="sites" match="Root/werbegruppe[gueltigkeit='Mi,Do,Fr,Sa']/vertriebsschiene[@name=$vs]" use="seite"/>
that was all i need.
Thanks for your help, im sure i will come back :D
Have a nice Weekend
|
|
 |