Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old March 8th, 2014, 09:42 AM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default multiple matches from another file

Dear all,

I have this file:

Code:
<TD>base, altar</TD>
and this other information here, which looks like this:

Code:
<skos:Concept rdf:about="http://www.eagle-network.eu/voc/objtyp/lod/53">
        <skos:prefLabel xml:lang="en">Basis</skos:prefLabel>
        <skos:altLabel xml:lang="es">base</skos:altLabel>
        <skos:altLabel xml:lang="tr">kaide</skos:altLabel>
        <skos:altLabel xml:lang="hu">lábazat</skos:altLabel>
        <skos:altLabel xml:lang="es">Pedestal</skos:altLabel>
        <skos:altLabel xml:lang="el">βάση (αγάλματος, μνημείου)</skos:altLabel>
        <skos:altLabel xml:lang="ru">база</skos:altLabel>
        <skos:altLabel xml:lang="ar">قاعدة</skos:altLabel>
        <skos:inScheme rdf:resource="http://www.eagle-network.eu/voc/objtyp/"/>
        <skos:exactMatch>
            <skos:Concept rdf:about="http://www.eagle-network.eu/voc/objtyp/lod/1338">
                <skos:prefLabel xml:lang="es">Pedestal (Basa, Base)</skos:prefLabel>
            </skos:Concept>
        </skos:exactMatch>
        <skos:exactMatch>
            <skos:Concept rdf:about="http://www.eagle-network.eu/voc/objtyp/lod/1336">
                <skos:prefLabel xml:lang="fr">Pidestal</skos:prefLabel>
            </skos:Concept>
        </skos:exactMatch>
        <dct:created>2013-10-01 22:44:21</dct:created>
    </skos:Concept>
<skos:Concept rdf:about="http://www.eagle-network.eu/voc/objtyp/lod/34">
        <skos:prefLabel xml:lang="de">Grabaltar</skos:prefLabel>
        <skos:altLabel xml:lang="en">altar, funerary</skos:altLabel>
        <skos:altLabel xml:lang="de">Altar, Grab</skos:altLabel>
        <skos:altLabel xml:lang="it">ara sepolcrale</skos:altLabel>
        <skos:altLabel xml:lang="la">ara, sepulcrum</skos:altLabel>
        <skos:altLabel xml:lang="fr">autel, tombeau</skos:altLabel>
        <skos:altLabel xml:lang="hu">síroltár</skos:altLabel>
        <skos:altLabel xml:lang="el">επιτύμβια στήλη</skos:altLabel>
        <skos:altLabel xml:lang="el">επιτύμβιο σήμα</skos:altLabel>
        <skos:altLabel xml:lang="ar">مذبح، جنائزي</skos:altLabel>
        <skos:inScheme rdf:resource="http://www.eagle-network.eu/voc/objtyp/"/>
        <dct:created>2013-10-01 22:44:21</dct:created>
    </skos:Concept>
what I want to do is create one element for each of the terms (base and altar), which contains an attribute with the value of the skosConcept in the second, like this:

Code:
<objectType ref="http://www.eagle-network.eu/voc/objtyp/lod/53">base</objectType>
<objectType ref="http://www.eagle-network.eu/voc/objtyp/lod/34"> altar</objectType>
I have tried to tokenize in a variable and then apply the following code (in which I also have to exclude "?" which might be contained in the initial file) to that, but after a lot of attempts, I renounced using tokenize(.,',') and the best I can get is, without tokenize, to match the first term only:

Code:
<objectType>
<xsl:variable name="noquestion">
<xsl:analyze-string select="normalize-space(TD[position()=6])" regex="(\*\s*\w*)\?">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:analyze-string select="." regex="(\w+),\s(\w*)">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:variable name="voc_term">
<xsl:value-of select="document('https://raw.github.com/PietroLiuzzo/epidocupconversion/master/allinone/eagle-vocabulary-object-type.rdf')//skos:prefLabel[lower-case(.)=lower-case($noquestion)]/parent::skos:Concept/@rdf:about"/><xsl:value-of select="document('https://raw.github.com/PietroLiuzzo/epidocupconversion/master/allinone/eagle-vocabulary-object-type.rdf')//skos:altLabel[lower-case(.)=lower-case($noquestion)]/parent::skos:Concept/@rdf:about"/></xsl:variable>
<xsl:if test="$voc_term!=''">
<xsl:attribute name="ref">
<xsl:value-of select="$voc_term"/>
</xsl:attribute></xsl:if>
<xsl:value-of select="normalize-space(TD[position()=6])"/>
</objectType>
and get this:

Code:
<objectType ref="http://www.eagle-network.eu/voc/objtyp/lod/53">base, altar</objectType>
Could somebody please advise me to where my mistake is?

Thank you very much





Similar Threads
Thread Thread Starter Forum Replies Last Post
Matches help JohnBampton XSLT 4 August 11th, 2009 10:03 AM
Unable to get multiple matches iinf BOOK: Beginning Regular Expressions 1 October 9th, 2008 02:18 PM
Displaying 1 to 9 of 9 matches kumiko Classic ASP Basics 2 February 21st, 2008 05:12 PM
matches without repeated items pongup BOOK: Beginning Regular Expressions 0 April 7th, 2007 09:05 PM
Make sure the class defined in this file matches . Tawanda BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 September 20th, 2006 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.