[xquery-talk] novice questions mailing list

David Lee dlee at calldei.com
Thu Dec 12 17:28:15 PST 2013


I lead you down the wrong path, I'm sorry.
The question you are asking is about XSLT not xpath or xquery although they share many things ... So many x's in XML land ...
I suggest this mailing list xsl-list at lists.mulberrytech.com



Sent from my iPad (excuse the terseness) 
David A Lee
dlee at calldei.com


> On Dec 12, 2013, at 6:38 PM, "e-letter" <inpost at gmail.com> wrote:
> 
>> On 12/12/2013, David Lee <dlee at calldei.com> wrote:
>> I think you will find this list very accommodating to basic questions.
>> All of us on this list knew nothing about xpath at one point.
>> 
>> I recommend with any question you supply sample XML and good description of
>> what you are trying to accomplish along with any xpath or xquery code you
>> have attempted
>> and what it produced and why you belive it is the wrong result.
>> 
> 
> Here goes:
> 
> The objective is to learn how to select nodes in an xml file and use
> xpath and xslt to select nodes of interest and display in a new file.
> 
> An xml file was created:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <!-- Edited by XMLSpy®, taken from http://www.w3schools.com-->
> <?xml-stylesheet type='text/xsl" href="xstylesheetexample.xslt" ?>
> <bookstore>
>    <book category="COOKING">
>        <title lang="en">Everyday Italian</title>
>        <author>Giada De Laurentiis</author>
>        <year>2005</year>
>        <price>30.00</price>
>    </book>
>    <book category="CHILDREN">
>        <title lang="en">Harry Potter</title>
>        <author>J K. Rowling</author>
>        <year>2005</year>
>        <price>29.99</price>
>    </book>
>    <book category="WEB">
>        <title lang="en">XQuery Kick Start</title>
>        <author>James McGovern</author>
>        <author>Per Bothner</author>
>        <author>Kurt Cagle</author>
>        <author>James Linn</author>
>        <author>Vaidyanathan Nagarajan</author>
>        <year>2003</year>
>        <price>49.99</price>
>    </book>
>    <book category="WEB">
>        <title lang="en">Learning XML</title>
>        <author>Erik T. Ray</author>
>        <year>2003</year>
>        <price>39.95</price>
>    </book>
> </bookstore>
> 
> An xml stylesheet was created:
> 
> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:import href="xqueryexampledata.xml"/>
>    <xsl:output
>        method="xml"
>        doctype-public="-//W3C//DTD XHTML Basic 1.1//EN"
>        doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"
>        encoding="utf-8"
>        indent="no"
>        omit-xml-declaration="yes"
>        media-type="text/xml"
>        standalone="yes"
>        version="1.1"
>        />
>    <xsl:template
>        match="author">
>        <html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
>            <head>
>                <meta
>                    name='note' content='xhtml document created by xml transformation' />
>                <title>Test output web page</title>
>            </head>
>            <body>
>                <p>
>                    <xsl:apply-templates/>
>                </p>
>            </body>
>        </html>
>    </xsl:template>
> </xsl:stylesheet>
> 
> The text editor 'jedit' is used with xml plugins xslt, xquery, xml.
> The xslt transformer plugin is used to select the above xml file and
> xslt file for subsequent transformation, to create an output xhtml
> file.
> 
> The result of this transformation is the creation of a new xhtml file
> (as stated in the stylesheet above):
> 
> 
>    
>        Everyday Italian
>        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
> "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>Giada De Laurentiis</p></body></html>
>        2005
>        30.00
>    
>    
>        Harry Potter
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>J K. Rowling</p></body></html>
>        2005
>        29.99
>    
>    
>        XQuery Kick Start
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>James McGovern</p></body></html>
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>Per Bothner</p></body></html>
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>Kurt Cagle</p></body></html>
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>James Linn</p></body></html>
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>Vaidyanathan Nagarajan</p></body></html>
>        2003
>        49.99
>    
>    
>        Learning XML
>        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> lang="en"><head><meta content="xhtml document created by xml
> transformation" name="note" /><title>Test output web
> page</title></head><body><p>Erik T. Ray</p></body></html>
>        2003
>        39.95
>    
> 
> Clearly, there's a lot to learn in specifying the transformation correctly!
> 
> The ideal output is:
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
> "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
>    <html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
>        <head>
>            <meta
>                content="xhtml document created by xml transformation" name="note"
>                />
>            <title>Test output web page</title>
>        </head>
>        <body>
>            <p>Giada De Laurentiis</p>
>            <p>J K. Rowling</p>
>            <p>James McGovern</p>
>            <p>Per Bothner</p>
>            <p>Kurt Cagle</p>
>            <p>James Linn</p>
>            <p>Vaidyanathan Nagarajan</p>
>            <p>Erik T. Ray</p>
>        </body>
>    </html>



More information about the talk mailing list