473,761 Members | 5,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

${...} values in attributes of an imported XML in XSL ...

I am a bit puzzled and don't know where to look for.
Here is a stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE stylesheet [
<!ENTITY foo SYSTEM "foo.xml">
]>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
indent="yes">
</xsl:output>

<xsl:template match="/">
<xsl:apply-templates select="node()| @*"/>
</xsl:template>

<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="/foohere">
&foo;
</xsl:template>
</xsl:stylesheet>
Now, everything happens appropriately. The first two template rules do
the identity transformation,
then when "/foohere" is found, the foo.xml is added to the result tree
having resolved the entity. All is well.

But in the result tree, I see that there are some weird things that
happen:
- for the portion that comes from foo.xml all occurrences of "${xyz}"
are replaced by "$".

How can I make it take the foo.xml "verbatim"? I have already tried
<xsl:text disable-output-escaping="yes"& foo; </xsl:text>, but it does
not work.

Thanks for help.

DB

Nov 8 '06 #1
5 1325
- for the portion that comes from foo.xml all occurrences of "${xyz}"
are replaced by "$".
You're inserting the contents of foo.xml into the stylesheet. That means
its contents are going to be interpreted as XSLT. Depending on where
these are occurring, they may be interpreted as Attribute Value Templates.

You may want to copy this using the document() function instead.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 8 '06 #2

Joe Kesselman wrote:
- for the portion that comes from foo.xml all occurrences of "${xyz}"
are replaced by "$".

You're inserting the contents of foo.xml into the stylesheet. That means
its contents are going to be interpreted as XSLT. Depending on where
these are occurring, they may be interpreted as Attribute Value Templates.

You may want to copy this using the document() function instead.
That's a great advice, thank you. I did not realize that the entity
resolution occurs *for the XSLT* and hence in effect, the XSLT is
modified. Let me take a look at the document() function and report
back.

Thank you, again.
>

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 8 '06 #3
Yes, document() function works, thank you.

Can you also tell me how to write out (template rule such that) an xml
element as-is, except that all the attributes should be sorted
lexically?

For the benefit of others:

Here is the working version that deals with use of document:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="foo" select="'foo.ht ml'"/>
<xsl:output method="xml"
indent="yes">
</xsl:output>

<xsl:template match="/">
<xsl:apply-templates select="node()| @*"/>
</xsl:template>

<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="/foohere">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
<xsl:copy-of select="documen t($foo)//"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Dhurandhar Bhatvadekar wrote:
Joe Kesselman wrote:
- for the portion that comes from foo.xml all occurrences of "${xyz}"
are replaced by "$".
You're inserting the contents of foo.xml into the stylesheet. That means
its contents are going to be interpreted as XSLT. Depending on where
these are occurring, they may be interpreted as Attribute Value Templates.

You may want to copy this using the document() function instead.

That's a great advice, thank you. I did not realize that the entity
resolution occurs *for the XSLT* and hence in effect, the XSLT is
modified. Let me take a look at the document() function and report
back.

Thank you, again.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 8 '06 #4
Dhurandhar Bhatvadekar wrote:
Can you also tell me how to write out (template rule such that) an xml
element as-is, except that all the attributes should be sorted
lexically?
The order of attributes is explicitly NOT MEANINGFUL in XML, and XML
tools make absolutely no promises that order will be preserved. If order
is semantically important, you shoud use child elements rather than
attributes.

If the order matters for non-semantic reasons (for example, if you're
trying to do a simple text comparison between two XML files), you can
try looking for a tool that converts the XML into Canonical Form
(http://www.w3.org/TR/xml-c14n), and apply that after the stylesheet has
run. Or you could write your own XML serializer that outputs in
canonical form. Or you could find a solution that doesn't require
canonicalizatio n, eg using an XML-aware file comparison tool.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 8 '06 #5
By the way... If you really, absolutely, insist upon trying to order the
attributes using XSLT you could probably do it, but you'd have to
reimplement the XML serializer in XSLT and output in text mode. Very
emphatically NOT a recommended solution.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 8 '06 #6

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

Similar topics

2
2437
by: Andrew Degtiariov | last post by:
Hello! I tried to rewrite my python module in C. My module is successfully imported but i can't assing anything to class attributes (tp_setattr in PyTypeObject for class FlowReportRow filled up by pointer to FlowReportRowObjectSetAttr function and printf in ones show the function does not called) Where I was mistaken? (you may see the module sources at http://astral.ua/~ad/Report.c) I wrote simple test:
1
1201
by: David Manheim | last post by:
I am writing a module which is supposed to allow use of a set of attributes in any XML document; there is a DTD for XHTML, but it will need to work with all XML data types when imported. I have written the Qname module, which I am having a bit of trouble trying to verify (mostly simply because I haven't written the rest of the module, I believe) but the main problem I am having is that I am unsure how to make the attributes common to all...
4
1981
by: louissan | last post by:
Hi all, I'm coming across a problem, and really do not get where it comes from. The goal: to loop over attributes read from "object" nodes in an imported XML file/flow (via XMLHTTP) and transform them into HTML/DOM attributes.
0
2650
by: Inna | last post by:
Hello all, I have DTS package that is importing data from multiple large Excel files from same directory into 1 database table. The structures are same and sizes of the .xls files are good. The problems come after all files are successfully imported. The problem: All contents are formatted as General. I have 2 types of values in same column First scenario:
16
1938
by: John Salerno | last post by:
Let's say I'm making a game and I have this base class: class Character(object): def __init__(self, name, stats): self.name = name self.strength = stats self.dexterity = stats self.intelligence = stats self.luck = stats
1
2298
by: nitusa | last post by:
Hi All, First time poster, and newbie C# programmer so be patient with my ignorance. :) For my current project I need to store some information (install dir., file names, passwords, ect.) and then have my program access those values. I choose to store the information in an XML file based on a recommendation from a peer. I am also new to XML but my current file setup looks like this: <?xml version="1.0" encoding="utf-8" ?>...
26
1907
by: tjhnson | last post by:
Hi, With properties, attributes and methods seem very similar. I was wondering what techniques people use to give clues to end users as to which 'things' are methods and which are attributes. With ipython, I use tab completion all the time, but I can rarely tell from the names alone whether it is an attribute or method. Tips? Ideas? Best practices?
0
1730
by: Kavitha Sudhershan | last post by:
hi, i wanna read the node values from xml. As per my code i can read the node values in first child node and for the next node am not able to read the node values. pls help me. i'll paste the code below: Sub readfile() objxmldom.async = False objxmldom.Load ("D:\CRT\rules\AQUA.xml")
0
895
by: Nathan Sokalski | last post by:
I am attempting to add Attributes to my ASP.NET Controls & Properties. Here is what my Controls look like: <ToolboxData("<{0}:Parameter runat=""server""/>")_ Public Class Parameter : Inherits System.Web.UI.Control Private _name As String <Description("My Property Description")_ Public WriteOnly Property Name() As String Set(ByVal value As String)
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
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
9989
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
8814
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 project—planning, coding, testing, and deployment—without 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
6640
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
5266
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...
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.