473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

XSL select pattern for root element with schema

[sorry for the possible dupe]

OK, I have a problem which I'm guessing is simply my inability to
figure out a select pattern in XSL.
I have an XML file similar to the following:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="vmv.xsl"?>
<ruleset xmlns="https://foo.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://foo.com vmv.xsd">
<rule>
<name>FIND_SGID_LOCAL</name>
<desc>Examine the sgid files.</desc>
<vdesc>Test</vdesc>
<expected/>
<code/>
<command>
<command>ls</command>
<parse>tes</parse>
<desc>test</desc>
<vdesc>test</vdesc>
</command>
<os name="linux" enabled="true"/>
</rule>
</ruleset>
I wold like to be able to provide a "pretty" version via the vmv.xsl
file ref'd in the markup above.
Here is a simplified version of the XSL file:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>Audit Rules</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Name</th>
<th align="left">Description</th>
</tr>
<xsl:for-each select="ruleset/rule">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="desc"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


My problem is that the select in the <xsl:for-each/> statement does not
match the root node, presumably because of the inclusion on the XML file
of the schema in the <ruleset/> attributes.
If I delete the schema info from <ruleset/> in the XML file, then the
table I generate in the XSL file works properly. THat's why I'm sure
I've just got to figure out the correct select pattern for the
<xsl:for-each/> statement.
Any suggestions out there?
Thanks in advance,
David
Jul 20 '05 #1
2 7397


David Nedrow wrote:

I have an XML file similar to the following:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="vmv.xsl"?>
<ruleset xmlns="https://foo.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://foo.com vmv.xsd">
<rule>
<name>FIND_SGID_LOCAL</name>
<desc>Examine the sgid files.</desc>
<vdesc>Test</vdesc>
<expected/>
<code/>
<command>
<command>ls</command>
<parse>tes</parse>
<desc>test</desc>
<vdesc>test</vdesc>
</command>
<os name="linux" enabled="true"/>
</rule>
</ruleset>
I wold like to be able to provide a "pretty" version via the vmv.xsl
file ref'd in the markup above.
Here is a simplified version of the XSL file:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>Audit Rules</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Name</th>
<th align="left">Description</th>
</tr>
<xsl:for-each select="ruleset/rule">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="desc"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


My problem is that the select in the <xsl:for-each/> statement does not
match the root node, presumably because of the inclusion on the XML file
of the schema in the <ruleset/> attributes.


Your elements in the XML file are in the namespace https://foo.com,
declare a prefix for that namespace in the XSLT stylesheet e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foo="https://foo.com">
and then use that prefix in your pattern/XPath expressions e.g.
<xsl:for-each select="foo:ruleset/foo:rule">
<xsl:value-of select="foo:name" />
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin,

Thanks, that got me going.

-David
Martin Honnen wrote:


Your elements in the XML file are in the namespace https://foo.com,
declare a prefix for that namespace in the XSLT stylesheet e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foo="https://foo.com">
and then use that prefix in your pattern/XPath expressions e.g.
<xsl:for-each select="foo:ruleset/foo:rule">
<xsl:value-of select="foo:name" />

Jul 20 '05 #3

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

Similar topics

4
by: MichaelD | last post by:
Hi! How do I combine an element pattern with attributes? I can validate <phone>111-111-1111</phone> using pattern
3
by: Sascha Kerschhofer | last post by:
If I define more than one element "globally" in an XML schema, is there any hint which one is the actual root element for any instance document? e.g. <xs:schema...
4
by: Mythran | last post by:
I have a file I'm using as a Configuration file (configuration as in options and such). When I create the xml file in the .Net IDE, it places the following (snip): <Configuration xmlns="Blah">...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
1
by: Daniel Serodio | last post by:
Is it possible to have an element which is both restricted by a pattern and nillable? Example schema: <xs:simpleType name="cpfType"> <xs:restriction base="xs:string"> <xs:pattern...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
8
by: VK | last post by:
Can be multiple instances of element used as the root element? That's a curly way of asking, but I did not come up with a better sentence, sorry. What I mean is with a document like: <?xml...
0
by: Dave Hill | last post by:
Forgive a newbie question. I'm learning the .NET XML environment. In the walkthrough on using XML designer to create an xsd, there is no discussion of the root element of the target xml document....
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.