www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: xslt question : i'm going stupid

  1. #1
    Join Date
    May 2003
    Posts
    10

    xslt question : i'm going stupid

    new to xslt, but i though i understood it.

    Take this exml for example :



    <?xml version="1.0" encoding="UTF-8"?>

    <!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by sis ICS-FORTH (ISL-ICS) -->

    <!-- <!DOCTYPE lom SYSTEM "imsmd_v1p2p2.dtd"> -->

    <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">

    <general>

    <title>

    <langstring xml:lang="en"> Resumes and Interviews </langstring>

    </title>

    </lom>
    ---------------------------------------

    Now, What I want to do is just print the title in between two <h1> </h1> brackets. eg. the xslt code that should do it imo

    <xsl:stylesheet version = '1.0'

    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

    <xsl:template match="/lom/general/title">

    <h1>

    <xsl:value-of select="langstring"/>

    </h1>

    </xsl:template>

    </xsl:stylesheet>



    But it doesn't work.... where is my logic incorrect? can anyone help me?

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    You are missing end tag for general element


    <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
    <general>
    <title>
    <langstring xml:lang="en"> Resumes and Interviews </langstring>
    </title>
    </general>
    </lom>

  3. #3
    Join Date
    May 2003
    Posts
    10
    ya, sorry, that isn't the problem, I just forgot to put the </general> tag in when i pasted it.

    Here is the whole XML file :
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by sis ICS-FORTH (ISL-ICS) -->
    <!-- <!DOCTYPE lom SYSTEM "imsmd_v1p2p2.dtd"> -->
    <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
    	<general>
    		<title>
    			<langstring xml:lang="en"> Resumes and Interviews </langstring>
    		</title>
    		<catalogentry>
    			<catalog>URI</catalog>
    			<entry>
    				<langstring xml:lang="en"> http://url.forthismovie.ca/resumes.mov</langstring>
    			</entry>
    		</catalogentry>
    		<catalogentry>
    			<catalog>POOL</catalog>
    			<entry>
    				<langstring xml:lang="en"> 000SamplePoolRefernece#2</langstring>
    			</entry>
    		</catalogentry>
    		<description>
    			<langstring xml:lang="en">Description: An interview with Lorna Court, Personnel Consultant, on how to impress employers with your resume. Court gives practical advice on what to put in your resume in order to secure an interview.</langstring>
    		</description>
    	</general>
    	<lifecycle>
    		<contribute>
    			<role>
    				<source>
    					<langstring xml:lang="x-none">LOMv1.0</langstring>
    				</source>
    				<value>
    					<langstring xml:lang="x-none">Author</langstring>
    				</value>
    			</role>
    			<centity>
    				<vcard>
    
    BEGIN: vCard
    
    N: Heywood;Jeff
    
    END: vCard
    
    </vcard>
    			</centity>
    		</contribute>
    		<contribute>
    			<role>
    				<source>
    					<langstring xml:lang="x-none">LOMv1.0</langstring>
    				</source>
    				<value>
    					<langstring xml:lang="x-none"> Publisher </langstring>
    				</value>
    			</role>
    			<centity>
    				<vcard>
    
    BEGIN: vCard
    
    ORG: Open School TV
    
    ADR: Open School TV;555 Main Street;Vancouver;British Columbia;V5T 2U4
    
    END: vCard
    
    </vcard>
    			</centity>
    			<date>
    				<datetime>2001-02-01</datetime>
    			</date>
    		</contribute>
    	</lifecycle>
    	<metametadata>
    		<contribute>
    			<role>
    				<source>
    					<langstring xml:lang="x-none">LOMv1.0</langstring>
    				</source>
    				<value>
    					<langstring xml:lang="x-none">Creator</langstring>
    				</value>
    			</role>
    			<centity>
    				<vcard>
    
    BEGIN:vCard
    
    Fisher;Sue
    
    END:vCard
    
    </vcard>
    			</centity>
    		</contribute>
    		<contribute>
    			<role>
    				<source>
    					<langstring xml:lang="x-none">LOMv1.0</langstring>
    				</source>
    				<value>
    					<langstring xml:lang="x-none">Validator</langstring>
    				</value>
    			</role>
    			<centity>
    				<vcard>
    
    BEGIN: vCard
    
    ORG: POOL Project
    
    END: vCard
    
    </vcard>
    			</centity>
    			<date>
    				<datetime>2001-03-21</datetime>
    			</date>
    		</contribute>
    		<metadatascheme>CanCore 1.0</metadatascheme>
    		<metadatascheme>IEEELOM:1.0</metadatascheme>
    		<language>en</language>
    	</metametadata>
    	<technical>
    		<format>
    
    video/quicktime
    
    </format>
    		<location type="URI">
    
    http://uri.forthismovie.inpoolrepository.ca/resume.mov 
    
    </location>
    		<duration>
    			<datetime>0000-00-00T00:03:11</datetime>
    		</duration>
    	</technical>
    	<educational>
    		<intendedenduserrole>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Learner</langstring>
    			</value>
    		</intendedenduserrole>
    		<intendedenduserrole>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Author</langstring>
    			</value>
    		</intendedenduserrole>
    		<intendedenduserrole>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Teacher</langstring>
    			</value>
    		</intendedenduserrole>
    		<context>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Secondary Education</langstring>
    			</value>
    		</context>
    		<context>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Higher Education</langstring>
    			</value>
    		</context>
    		<typicalagerange>
    			<langstring xml:lang="en">12-99</langstring>
    		</typicalagerange>
    		<language>en</language>
    	</educational>
    	<rights>
    		<cost>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">yes</langstring>
    			</value>
    		</cost>
    		<copyrightandotherrestrictions>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">yes</langstring>
    			</value>
    		</copyrightandotherrestrictions>
    		<description>
    			<langstring xml:lang="en"> Rights expiry: in perpetuity. Contact publisher for conditions of use.
    
    </langstring>
    		</description>
    	</rights>
    	<classification>
    		<purpose>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Discipline</langstring>
    			</value>
    		</purpose>
    		<keyword>
    			<langstring xml:lang="en">Career planning </langstring>
    		</keyword>
    	</classification>
    	<classification>
    		<purpose>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">Idea</langstring>
    			</value>
    		</purpose>
    		<keyword>
    			<langstring xml:lang="en">job hunting</langstring>
    		</keyword>
    		<keyword>
    			<langstring xml:lang="en">resumes</langstring>
    		</keyword>
    		<keyword>
    			<langstring xml:lang="en">job applications</langstring>
    		</keyword>
    	</classification>
    	<classification>
    		<purpose>
    			<source>
    				<langstring xml:lang="x-none">LOMv1.0</langstring>
    			</source>
    			<value>
    				<langstring xml:lang="x-none">PedagogicType</langstring>
    			</value>
    		</purpose>
    		<taxonpath>
    			<source>
    				<langstring xml:lang="en">CanCore</langstring>
    			</source>
    			<taxon>
    				<entry>
    					<langstring xml:lang="en">Component</langstring>
    				</entry>
    			</taxon>
    		</taxonpath>
    	</classification>
    </lom>
    And the ONLY thing I'd like to select is the title

    Resume and Interviews and put in between <h1> </h1>

    /general/title/langstring

    can anyone help, I'm sure this is tupidly simple, I guess I just don't understand how these path's work.

    ..jordan

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    let me see,because I could get interviews and resume as the result..But looking at your xml it might change things..

  5. #5
    Join Date
    May 2003
    Posts
    10
    just to clarify, I would like to get the value between these tags :

    <title>
    <langstring xml:lang="en"> Resumes and Interviews </langstring>
    </title>

    -- > "Resumes and Interviews"

  6. #6
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    Here is the xsl code that will get the required value from xml file for you


    <?xml version='1.0'?>
    <xsl:stylesheet
    version = "1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xslutput method="html"/>
    <xsl:template match="lom">
    <h1>
    <xsl:value-of select="general/title/langstring"/>
    </h1>
    </xsl:template>
    </xsl:stylesheet>

  7. #7
    Join Date
    May 2003
    Posts
    10

    didn't work! thanks though!

    thanks, although, it still doesn't seem to work.

    this is the result i get :

    Code:
    Human Resource ManagementURI http://www.algonquincollege.com/distance/certfs.htmlPOOL 000SamplePoolRefernece#This course deals with personnel functions, including concepts, principles and practices; techniques of personnel administration (roles, staffing, human resources, employee development and incentives for effective performance); and management's responsibility in personnel administration.MGT2310LOMv1.0Publisher
    
    BEGIN: vCard
    
    ORG: Algonquin College
    
    END: vCard
    
    2001-02-01LOMv1.0Creator
    
    BEGIN:vCard
    
    Fisher;Sue
    
    END:vCard
    
    LOMv1.0Validator
    
    BEGIN: vCard
    
    ORG: POOL Project
    
    END: vCard
    
    2001-02-01CanCore 1.0IEEELOM:1.0entext/htm
    
    http://www.algonquincollege.com/distance/certfs.html
    
    Group Work is required for computer conferencingLOMv1.0LearnerLOMv1.0University Undergraduate18-99enLOMv1.0yesLOMv1.0yesRegistration $332.85 Can. Contact Carole Smith, csmith@algonquinc.on.caLOMv1.0DisciplineEricHuman ResourcesManagementLOMv1.0PedagogicTypeCanCoreCourse
    Again, your logic seems sound, but it just doesn't seem to work. Have you gotten it to work? I use XMLspy, and it isn't working in there!

    It seems to be printing out all values contained within any tag named 'langstring' rather than the one we want.



    I'm so confused!

    ..jordan willms

  8. #8
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653

    Re: didn't work! thanks though!

    Originally posted by willms_jay
    thanks, although, it still doesn't seem to work.

    .......
    I have it working,the error must be in rest of the xslt code.

    Here is the link where I have it working.

    http://68.145.35.86/temp/willms_jay/wjay.xml

  9. #9
    Join Date
    May 2003
    Posts
    10
    YES!

    Here's the thing I don't understand.

    It worked when i did the following like you :

    Code:
    <lom>
    but it doesn't work when it is like this :

    Code:
    <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
    WHY?

    Also, I am recieving these files as is, so how am I going to edit them to remove all the attributes after the lom tag?

    Also.

    Why is this even causing a problem in the first place!??!

    ..jordan

  10. #10
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    That probably has to do something specifically prprietery crap by MS,I hope I am wrong,but I don't see any reason why it would not work.

  11. #11
    Join Date
    May 2003
    Posts
    10
    i'm not using ms though, I am using xmlspy.

    But why did you remove it in the firstplace, were you getting the same errors?

    ..jordan

  12. #12
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    I removed so that I knew I was not pointing to any MS specific schema..

    This is the line that is causing problem

    xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2"

    I'll try to see what exactly it could have caused.

  13. #13
    Join Date
    May 2003
    Posts
    10
    it's actually not MS schema.

    It stands for

    IMS -- nothing to do with microsoft.

    man, i am so confused. thank you for helping. any additional help will be greatly appretiated.

    ..jordan willms

  14. #14
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    I used wrong words,
    I meant it points to a proprietery resource,for which I am afraid I have no Idea what could be wrong.I could help as long as the code is w3c standard,,,,

  15. #15
    Join Date
    May 2003
    Posts
    10
    in the end i had to do this :

    Code:
    <?xml version="1.0"?> 
    <xsl:stylesheet xmlns:cancore="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="xml" indent="yes"/>
    
    <xsl:template match="cancore:lom">
    		<xsl:apply-templates select="cancore:general" /> 
    </xsl:template>
    
    <xsl:template match="cancore:general">
    	<xsl:apply-templates select="cancore:title" /> 
    </xsl:template>
    
    <xsl:template match="cancore:title">
    	<xsl:apply-templates select="cancore:langstring" /> 
    </xsl:template>
    
    </xsl:stylesheet>
    because of some namespace bull****.

    what sucks, is how I can't do a

    <xsl:value-of select="canore:general/title/langstring" />

    for some reason it makes me do it like this template level by template level.

    ..confuseing.

    ..jordan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles