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 June 10th, 2008, 06:31 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL and colons

I need help on how to work in a colon tag. If I leave the ":" in I receive an error, however if I don't include I don't get the value needed.

Example:

<xsl:value-of select="/n1:ClinicalDocument/n1:documentationOf/n1:serviceEvent/n1:performer/n1:assignedEntity/n1:sdtc:patient/n1:sdtc:id/@extension"/>

 
Old June 10th, 2008, 06:34 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Can you show us the XML you want to process?
Is that well-formed XML with namespaces?

--
  Martin Honnen
  Microsoft MVP - XML
 
Old June 10th, 2008, 06:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A name that contains a colon is called a "Qualified Name" or QName. The part before the colon is a namespace prefix. It's a shorthand for the namespace URI, which tells you which namespace the name is in. To select elements or attributes that are in a namespace, you need to get the namespace right, just as you need to get the local name right.

Since you're clearly unfamiliar with the terminology, it looks to me as if you need to do some more reading around the subject. Wrox do some excellent books...

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 10th, 2008, 06:39 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

A colon in a XML element name is not valid - therefore you might be getting confused over your namespace declarations, but without seeing your source document and your namespace declarations its hard to say.

/- Sam Judson : Wrox Technical Editor -/
 
Old June 10th, 2008, 06:39 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

XML document is very lengthy, however here is the section that contains what I am wanting to capture.

<sdtc:patient>
<sdtc:id root="78A150ED-B890-49dc-B716-5EC0027B3983" extension="123456789" />
</sdtc:patient>

 
Old June 10th, 2008, 06:44 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Own that wonderful book that you speak of. You are correct I was unaware of QNames. Now that I know what to look for I will read up on this section.

Thanks!

 
Old June 10th, 2008, 06:45 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Assuming your input XML has e.g. xmlns:sdtc="http://example.com/foo" your stylesheet needs e.g.
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sdtc="http://example.com/foo"
  xmlns:n1="http://example.com/bar"
  version="1.0">

<xsl:template match="/">
<xsl:value-of select="/n1:ClinicalDocument/n1:documentationOf/n1:serviceEvent/n1:performer/n1:assignedEntity/sdtc:patient/sdtc:id/@extension"/>
--
  Martin Honnen
  Microsoft MVP - XML
 
Old June 10th, 2008, 09:07 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you!






Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
differnce between xsl:apply-templates and xsl:call chandu.mca007 XSLT 2 June 12th, 2007 04:12 AM
xsl advise needed - Replacing UID through XSL Billyl XSLT 6 February 28th, 2006 05:46 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





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