473,804 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prefix problem with XML/XSL

I'm experiencing the following problem

The source xml file uses a prefix (wpl:) and look like this (shortened):
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<wpl:Destinatio ns xmlns:wpl="www. sapportals.com/portal/landscape"
xmlns:xsi="http ://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocat ion="wpl_jco_de stionations_v10 .xsd">

<wpl:Destinatio n name="SAP_R3_Fi nancials_DEV200 ">
<wpl:SYSTEM>ZSE CDS1200</wpl:SYSTEM>
<wpl:MSHOST>sec acsap</wpl:MSHOST>
<wpl:R3NAME>DS1 </wpl:R3NAME>
<wpl:CLIENT>200 </wpl:CLIENT>
</wpl:Destination >
-----------------------------------------------------------------
The xsl file i created loos like this:
----------------------------------------------------------------
<?xml version="1.0" ?>
<wpl:styleshe et xmlns:wpl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<wpl:output method="text"/>

<wpl:template match="Destinat ion">
<wpl:value-of select="@name"/>
</wpl:template>

</wpl:stylesheet>
-------------------------------------------------------------------

I then run

xalan -o output.txt jcoDestinations .xml jcoDestinations .xsl

I would expect the output to be

SAP_R3_Financia ls_DEV200

however the output is:
ZSECDS1200
secacsap
DS1
200
I removed all the "wpl:" from the source, changed the xls to use "xsl"
rather than "wpl". This produces the expected output.

Is this a bug, or am I doing somthing wrong?
Regards
Jacques
Jul 20 '05 #1
3 4957
Jacques wrote:
I'm experiencing the following problem

The source xml file uses a prefix (wpl:) and look like this (shortened):
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<wpl:Destinatio ns xmlns:wpl="www. sapportals.com/portal/landscape"
xmlns:xsi="http ://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocat ion="wpl_jco_de stionations_v10 .xsd">

<wpl:Destinatio n name="SAP_R3_Fi nancials_DEV200 ">
<wpl:SYSTEM>ZSE CDS1200</wpl:SYSTEM>
<wpl:MSHOST>sec acsap</wpl:MSHOST>
<wpl:R3NAME>DS1 </wpl:R3NAME>
<wpl:CLIENT>200 </wpl:CLIENT>
</wpl:Destination >
-----------------------------------------------------------------
The xsl file i created loos like this:


maybe a tiny misunderstandin g

there's nothing wrong in your stylesheet (that is to say that it is a
correct stylesheet, although it doesn't produce the expected result)

however, your template doesn't handle elements from your xml source,
because you have to define a xmlns declaration with a prefix bound to
your data; as usually, the xslt namespace is bound to xsl, i recommend
to use the prefix xsl for the xslt namespace, and wpl for your own datas :

<?xml version="1.0" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:wpl="www. sapportals.com/portal/landscape"
version="1.0">

<xls:output method="text"/>

<xsl:template match="wpl:Dest ination">
<xsl:value-of select="@name"/>
</xsl:template>

</xsl:stylesheet>

you can see above that wpl:Destination matches the appropriate element
because the prefix is bound to the same uri (using the same prefix is
convenient but not mandatory)

the xsl prefix is bound to the uri that correspond to xslt, and will be
handled by your xslt processor

notice that unprefixed attributes are never bound to a namespace uri, so
one can safely use @name

what counts : only the univeral name, that consists of the namespace uri
and the local name (the name without the prefix); consider that a prefix
is just an alias, that is neutral

have a look at the namespace specification : a very little spec that
have a huge major importance in xml technologies

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #2
Jacques wrote:
I'm experiencing the following problem

The source xml file uses a prefix (wpl:) and look like this
(shortened):
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?> <wpl:Destinatio ns
xmlns:wpl="www. sapportals.com/portal/landscape"
xmlns:xsi="http ://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocat ion="wpl_jco_de stionations_v10 .xsd">

<wpl:Destinatio n name="SAP_R3_Fi nancials_DEV200 ">
<wpl:SYSTEM>ZSE CDS1200</wpl:SYSTEM>
<wpl:MSHOST>sec acsap</wpl:MSHOST>
<wpl:R3NAME>DS1 </wpl:R3NAME>
<wpl:CLIENT>200 </wpl:CLIENT>
</wpl:Destination >
-----------------------------------------------------------------
The xsl file i created loos like this:
----------------------------------------------------------------
<?xml version="1.0" ?>
<wpl:styleshe et xmlns:wpl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<wpl:output method="text"/>

<wpl:template match="Destinat ion">
<wpl:value-of select="@name"/>
</wpl:template>

</wpl:stylesheet>
-------------------------------------------------------------------

I then run

xalan -o output.txt jcoDestinations .xml jcoDestinations .xsl

I would expect the output to be

SAP_R3_Financia ls_DEV200

however the output is:
ZSECDS1200
secacsap
DS1
200
I removed all the "wpl:" from the source, changed the xls to use "xsl"
rather than "wpl". This produces the expected output.

Is this a bug, or am I doing somthing wrong?


The prefix is not important for namespace resolution. The namespace uri
is. In your xml file, all the elements are in the
www.sapportals.com/portal/landscape namespace, which your style sheet
doesn't know anything about.

Jul 20 '05 #3
Thank you for a very informative explanation, as well as a practical
solution.
It works now, and I understand why.

Regards

"Philippe Poulard" <Ph************ ****@SPAMsophia .inria.fr> wrote in message
news:cb******** **@news-sop.inria.fr...
Jacques wrote:
I'm experiencing the following problem

The source xml file uses a prefix (wpl:) and look like this (shortened):
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<wpl:Destinatio ns xmlns:wpl="www. sapportals.com/portal/landscape"
xmlns:xsi="http ://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocat ion="wpl_jco_de stionations_v10 .xsd">

<wpl:Destinatio n name="SAP_R3_Fi nancials_DEV200 ">
<wpl:SYSTEM>ZSE CDS1200</wpl:SYSTEM>
<wpl:MSHOST>sec acsap</wpl:MSHOST>
<wpl:R3NAME>DS1 </wpl:R3NAME>
<wpl:CLIENT>200 </wpl:CLIENT>
</wpl:Destination >
-----------------------------------------------------------------
The xsl file i created loos like this:


maybe a tiny misunderstandin g

there's nothing wrong in your stylesheet (that is to say that it is a
correct stylesheet, although it doesn't produce the expected result)

however, your template doesn't handle elements from your xml source,
because you have to define a xmlns declaration with a prefix bound to
your data; as usually, the xslt namespace is bound to xsl, i recommend
to use the prefix xsl for the xslt namespace, and wpl for your own datas :

<?xml version="1.0" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:wpl="www. sapportals.com/portal/landscape"
version="1.0">

<xls:output method="text"/>

<xsl:template match="wpl:Dest ination">
<xsl:value-of select="@name"/>
</xsl:template>

</xsl:stylesheet>

you can see above that wpl:Destination matches the appropriate element
because the prefix is bound to the same uri (using the same prefix is
convenient but not mandatory)

the xsl prefix is bound to the uri that correspond to xslt, and will be
handled by your xslt processor

notice that unprefixed attributes are never bound to a namespace uri, so
one can safely use @name

what counts : only the univeral name, that consists of the namespace uri
and the local name (the name without the prefix); consider that a prefix
is just an alias, that is neutral

have a look at the namespace specification : a very little spec that
have a huge major importance in xml technologies

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2873
by: Holger Joukl | last post by:
Hi there, 2 questions regarding build/installation issues: 1. In the python 2.3.3 setup.py script, the detect_modules method of class PyBuildExt contains the following code: 253 if os.path.normpath(sys.prefix) != '/usr': 254 add_dir_to_list(self.compiler.library_dirs, 255 sysconfig.get_config_var("LIBDIR")) 256 add_dir_to_list(self.compiler.include_dirs,
1
7310
by: Romeo Disca | last post by:
Hello newsgroup, i'm new to xml - what's wrong with this piece code here? i have these two files: test.xml ---- <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE a SYSTEM "test.ent"
4
20505
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet ss:Name="TKCSheet1"> </Worksheet> The existing xml doc is: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?>
4
7296
by: BizTalk Benjamin | last post by:
Hi, I have an XmlDocument loaded from a memory stream. I set the document element prefix in this way XmlElement e = xDoc.DocumentElement; e.Prefix = "abc" When i simply write the document element to the command line it shows the prefix. However, it does not persist in the XmlDoc so when i save the XmlDoc into a file, the prefix is no longer there.
5
6963
by: johanneskrueger | last post by:
Hello, I'm currently using <xsl:copy-of select="document(...)/svg:svg"/to embed an SVG file into an XHTML file. I already defined the SVG namespace and assigned svg as its prefix in my XSLT 1.0 sheet. What commands instead of copy-of could I use in order to get the prefix with every element from the external file, e.g. <svg:svg>, <svg:lineetc. instead of just <svgand <line>, as it is noted in the external file?
2
21647
by: scottpet | last post by:
Hi, I want to add a namespace prefix to the root node of an object I am serializing to XML. I have been reading though this article: http://msdn2.microsoft.com/en-gb/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx I get namespace prefixes in the document, but not on the root node. Specifically, the serializer does not work as described in the last
30
5504
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”. Likewise, they write “(if test this that)” to mean “if (test) {this} else {that}”. LISP codes are all of the form “(a b c ...)”, where the
8
7843
by: subramanian100in | last post by:
Consider int i = 10; Why do we say that ++i yields an Lvalue and i++ yields an Rvalue ? I thought both these expressions yield only values. I am unable to understand the difference
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.