Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: XSL schema

  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Location
    Cardiff, Wales.
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XSL schema

    Hey guys, first post so go easy on me. New to using XSL and also new to Schema btu we have a .net application that uses XSL to output XML files calling data such as contacts etc which I would like to add schema attributes to the xsl file so it automatically shows those attributes in the finished page.

    Here is the current XSL code, can someone show me how or where I would add the schema attributes? (just for reference, I have picked up this project 3 years after it was written and converting to C#. Not really had much to do with XSL before.

    Thanks in advance.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:template match="*">
            <xsl:if test="count(contact) &gt; 0">
    			<xsl:apply-templates select="contact" />
            </xsl:if>
        </xsl:template>
    
        <xsl:template match="contact">
    		<article class="contact">
    			<xsl:choose>
    				<xsl:when test="@image"><img src="/_resources/files{@image}" alt="Front Cover" /></xsl:when>
    				<xsl:otherwise><img src="/_resources/files/content/contacts/contacts-awaiting-image.jpg" alt="Awaiting Image" /></xsl:otherwise>
    			</xsl:choose>
                <h1><xsl:value-of select="@title" />. <xsl:value-of select="@name" /></h1>
                <p><xsl:value-of select="@position" /><xsl:if test="@company != 'IEF'"><xsl:text>*</xsl:text>(<xsl:value-of select="@company" />)</xsl:if><br /><xsl:value-of select="@telephone" /></p>
            </article>
        </xsl:template>
    
    </xsl:stylesheet>

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Welcome to CF! Usually we prefer new questions go in a new thread (you're resurrecting a really old one here), but I don't think there's anything specifically against that in the rules. (I could be wrong.)

    That said, you're not giving us enough information to work with. To use XSL to generate XML, you have to have a data source of some kind (XML, I believe). XML + XSL = other XML. Can you show us a sample of the source XML, and what you expect the result XML to look like?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

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