Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

XSLT parsing
 

David Walker




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
Hi,

I have an XML file created by a third party in which an element with a
simple content model has a text value consisting of 2 parts separated by a
colon, like this

<link>machine:port</link>

Is XSLT capable of parsing the value of a <link> element, to separately
extract the portions before and after the colon?

Regards
David Walker




Post Follow-Up to this message ]
Re: XSLT parsing
 

Andrew Urquhart




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
*David Walker* wrote:
> I have an XML file created by a third party in which an element with a
> simple content model has a text value consisting of 2 parts separated
> by a colon, like this
>
> <link>machine:port</link>
>
> Is XSLT capable of parsing the value of a <link> element, to
> separately extract the portions before and after the colon?

Yes, e.g.:

<xsl:template match="link">
<xsl:choose>
<xsl:when test="contains(., ':')">
<xsl:text>Before = "</xsl:text>
<xsl:value-of select="substring-before(., ':')"/>
<xsl:text>", after = "</xsl:text>
<xsl:value-of select="substring-after(., ':')"/>
<xsl:text>"</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

--
Andrew Urquhart
- CIWAS CSS FAQ: www.css.nu/faq/ciwas-aFAQ.html
- CIWAS Archive: www.tinyurl.com/ysjbm (Google Groups)
- My reply address is invalid, use: www.andrewu.co.uk/contact/




Post Follow-Up to this message ]
Re: XSLT parsing
 

Harlan Messinger




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
"David Walker" <david@cs.cf.ac.uk> wrote:

>Hi,
>
>I have an XML file created by a third party in which an element with a
>simple content model has a text value consisting of 2 parts separated by a
>colon, like this
>
><link>machine:port</link>
>
>Is XSLT capable of parsing the value of a <link> element, to separately
>extract the portions before and after the colon?

I suppose a question about XSLT is a bit more relevant to a group on
style sheets than to a group like, say, rec.knitting...but really,
what is this doing here?

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.


Post Follow-Up to this message ]
Re: XSLT parsing
 

Andrew Urquhart




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
*Harlan Messinger* wrote:
> *David Walker* wrote: 
>
> I suppose a question about XSLT is a bit more relevant to a group on
> style sheets than to a group like, say, rec.knitting...but really,
> what is this doing here?

comp.infosystems.www.authoring. /stylesheets/

XSLT; extensible /stylesheet/ language transformations

CSS and XSLT are both stylesheets.
To quote the FAQ:

'At the moment, almost all discussion on this group relates to CSS,
although that might not always be so. This document does not aim
to be a complete tutorial in stylesheets or in CSS.'

Pragmatically speaking comp.text.xml is more applicable at the present
time, but that is not obvious given this newsgroups dual purpose name.
Personally I'd prefer to see a comp.text.xml.xslt group, XSLT being a
subset of XML.
--
Andrew Urquhart
- CIWAS CSS FAQ: www.css.nu/faq/ciwas-aFAQ.html
- Archive: www.tinyurl.com/ysjbm (Google Groups)
- My reply address is invalid, use: www.andrewu.co.uk/contact/




Post Follow-Up to this message ]
Re: XSLT parsing
 

Harlan Messinger




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
"Andrew Urquhart" <useWebsiteInSignatureToReply@spam.invalid> wrote in
message news:XhDAc.150$in5.136@newsfe1-win...
> *Harlan Messinger* wrote: 
>
> comp.infosystems.www.authoring. /stylesheets/
>
> XSLT; extensible /stylesheet/ language transformations
>
> CSS and XSLT are both stylesheets.
> To quote the FAQ:
>
>     'At the moment, almost all discussion on this group relates to CSS,
>      although that might not always be so. This document does not aim
>      to be a complete tutorial in stylesheets or in CSS.'
>
> Pragmatically speaking comp.text.xml is more applicable at the present
> time, but that is not obvious given this newsgroups dual purpose name.
> Personally I'd prefer to see a comp.text.xml.xslt group, XSLT being a
> subset of XML.

Ah. Understood. I apologize.



Post Follow-Up to this message ]
Re: XSLT parsing
 

Kimmo J?rvikangas




quote this post edit post

IP Loged report this post

Old Post  06-18-04 - 05:15 PM  
"David Walker" <david@cs.cf.ac.uk> wrote in message news:<caug5e$61h$1@news.swman.net.uk>..
.
> Hi,
>
> I have an XML file created by a third party in which an element with a
> simple content model has a text value consisting of 2 parts separated by a
> colon, like this
>
> <link>machine:port</link>
>
> Is XSLT capable of parsing the value of a <link> element, to separately
> extract the portions before and after the colon?
>
> Regards
> David Walker

David,

I suppose there are many ways of achieving that. Here is just one example:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transfor
m">
<xsl:template match="/">
<xsl:apply-templates select="link"/>
</xsl:template>
<xsl:template match="link">
<xsl:variable name="machine" select="substring-before( . , ':' ) "/>
<xsl:variable name="port" select="substring-after( . , ':' ) "/>
<xsl:element name="link">
<xsl:element name="machine">
<xsl:value-of select="$machine"/>
</xsl:element>
<xsl:element name="port">
<xsl:value-of select="$port"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

This will transform Your example

<?xml version="1.0" encoding="UTF-8"?>
<link>machine:port</link>

To the following:

<?xml version="1.0" encoding="UTF-8"?>
<link>
<machine>machine</machine>
<port>port</port>
</link>

Is this something like You were after?

Rgds,

<kimmo/>


Post Follow-Up to this message ]
Re: XSLT parsing
 

Jan Roland Eriksson




quote this post edit post

IP Loged report this post

Old Post  06-19-04 - 12:16 AM  
On Fri, 18 Jun 2004 08:47:42 -0400, Harlan Messinger
<hmessinger.removethis@comcast.net> wrote:

>"David Walker" <david@cs.cf.ac.uk> wrote:
[...] 

>I suppose a question about XSLT is a bit more relevant to a group on
>style sheets than to a group like, say, rec.knitting...but really,
>what is this doing here?

This NG is not restricted to only discuss CSS, in fact any stylesheet
technology that is applicable to the www may be discussed here.

http://css.nu/faq/ciwas-mFAQ.html#C02

--
Rex



Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 04:12 AM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top