473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

for-each IDREF

Dormilich
8,658 Expert Mod 8TB
Hello,

I'm back with a problem, where I need help with starting.
I got an XML file that contains a number of elements with IDREF type attributes:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" ?>
  2. <root>
  3. // these elements contain all the info for the groups
  4. // name is of type ID
  5.   <group name="group1" … />
  6.   <group name="group2" … />
  7.   <group name="group3" … />
  8.   <collection>
  9. // group is of type IDREF
  10. // there can be any number of elements
  11.     <item group="group1">…</item>
  12.     <item group="group1">…</item>
  13.     <item group="group2">…</item>
  14.   <collection>
  15. <root>
in XSL I want to loop over each group of <item> inside the <collection> (ideally using the idref() function) but I do not know all the values of the IDREF attribute (this number may change over time/file/element). Is there any way to get these values?
Expand|Select|Wrap|Line Numbers
  1. // desired result
  2. <div id="group1">
  3.   <a … >
  4.   <a … >
  5. </div>
  6. <div id="group2">
  7.   <a … >
  8. </div>
I know that I could loop over all elements (using <xsl:sort>) and check if the attribute value is still the same. Is there a more elegant way? (something like getting the IDREF attribute values first and then call it by idref() (or @group))

Is it possible to somehow get all the ID values of <group> and iterate over each of them?

thanks

PS: once I know all the IDREFS inside <collection> there are no problems I can foresee
Dec 8 '08 #1
4 2477
jkmyoung
2,057 Expert 2GB
Do you mean this? If not, what more are you looking for; what do you mean by idref? Is this a processor specific function, eg Xalan?

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="group">
  2.   <div id="{@name}">
  3.     <xsl:apply-templates select="//collection/item[@group = current()/@name]"/>
  4.   </div>
  5. </xsl:template>
  6.  
Dec 8 '08 #2
Dormilich
8,658 Expert Mod 8TB
@jkmyoung
I mean this:
Expand|Select|Wrap|Line Numbers
  1. <!ELEMENT item ...>
  2. <!ATTLIST item 
  3.     group    IDREF    #IMPLIED
  4.     ... >
I'll dive into the code tomorrow...

regards

PS: XML Schema also know ID/IDREF type attribute definitions
Dec 8 '08 #3
Dormilich
8,658 Expert Mod 8TB
currently I'm looking into muenchian grouping. will post back if I can see some light....
Dec 9 '08 #4
Dormilich
8,658 Expert Mod 8TB
solved it using Muenchian Grouping (pretty much the thing I needed).
files (too long to post):
XML (gives YSOD in FF)
XSL
DTD
Dec 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): ...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
0
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to...
0
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the...
0
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was...
33
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
4
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that...
0
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2...
5
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.