473,890 Members | 1,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting Data from Schema Tags

Hi All,

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?

-James

Jul 20 '05 #1
4 1605


Porthos wrote:

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?


A W3C XML schema is XML and can therefore certainly be processed by a
W3C XSLT stylesheet and there you can use
<xsl:value-of select="element name" />
to get the string value of an element with name 'elementname'.

It is not clear to me what you are asking about, do you have a W3C XML
schema and want to process that with an XSLT stylesheet? Inside of such
a schema an element is defined as follows e.g.
<xs:element name="elementna me" type="xs:string " />
so an XSLT stylesheet could then go and read out
<xsl:value-of
xmlns:xs="http://www.w3.org/2001/XMLSchema"
select="xs:elem ent/@name" />
If the element has complex content then its declaration looks like e.g.
<xs:element name="elementna me">
<xs:complexType >
<xs:sequence>
<xs:element name="element2n ame" />
</xs:sequence>
</xs:complexType>
</xs:element>
then of course a stylesheet trying to process that needs to make sure it
processes subelements like complexType or sequence.
But as I am not sure what you are looking for it is not possible to give
a concrete example.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
"Porthos" <ja*****@vt.edu > writes:
Hi All,

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
Note "My Data Here" is not contained in any tag (that's essentially the
definition of being data rather than markup) XSLT doesn't have access to
the tags in the original source file. It's _between_ the start tag and
end tag (each of which contain the element type name "tag").
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?


A schema file is just a normal XML file as far as XSLT is concerned
there are no special rules at all. However two guesses as to what might
be wrong:

if you are using unprefixed element names such as
<xsl:value-of select="element "/>
then this matches element in no-namespace and you need to match element
in the namespace http://www.w3.org/2001/XMLSchema so you need
<xsl:value-of select="xs:elem ent"/>
together with xmlns:xs="http://www.w3.org/2001/XMLSchema" on your
xsl:stylesheet.

secondly rather few xsd elements have character data content, they
almost all have element content with data being in attributes, for any
such element xsl:value-of will always return the empty string as
it just gives the character data of any descendent element of an
element node.

So you might want for example

<xsl:value-of select="xs:elem ent/@ref"/>

to pull out a ref attribute.

David
Jul 20 '05 #3
Martin,

I have a custom XML schema (.xsd file) and want to process that with
XSLT stylesheet. The schema contains <annotation> tags of the
following general format:

<xsd:schema ...>
<annotation>
<appinfo>
<mytag1>Human Readable Information 1</mytag1>
<mytag2>Human Readable Information 2</mytag2>
</appinfo>
</annotation>
Jul 20 '05 #4
I assumed that since the schema document is an XML document
itself, I could use <xsl:value-of select="mytag1"/>


If the default namespace in your schema file is no-namespace and the
current node at that point in your stylesheet is the xs:appinfo node
then <xsl:value-of select="mytag1"/> will produce
Human Readable Information 1

so if that isn't happening either the element mytag1 isn't in
no-namespace or the current node is not xs:appinfo, but you haven't
shown enough context to guess which.

David
Jul 20 '05 #5

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

Similar topics

5
5194
by: Markus Ernst | last post by:
Hello I have a regex problem, spent about 7 hours on this now, but I don't find the answer in the manual and googling, though I think this must have been discussed before. I try to simply extract the title and meta tags of a valid HTML page as an array: function extract_html($filename)
1
4626
by: ruthless | last post by:
hello. i've got a question can i in XML Schema define tag that works as lists knows from e.g. C,C++ - recurrent tags? i'm talking about e.g. genealogical tree every level of this tree is the same
0
1211
by: Vika Zafrin | last post by:
Hello, group. I am working with some texts, literary and otherwise, marking them up as I go, without a set DTD. I do not plan to have a DTD in place at all, at least not for the encoding part of the exercise. What I would like is for oXygen (which I use on Mac OS X) to "remember" the elements, attributes and values I've used so far in this project. I tried using the "project" feature, but to no avail: I can create a schema, but the...
5
3689
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail validation? The former seems to be an easier question to answer. XML files will arrive from around the world and must be schema validated before further processing and loading into a database, so I'm trying to foresee the various layouts that might be...
4
3087
by: james.eaton | last post by:
I have an XML Schema Document (.xsd) that contains documentation tags (specifically, custom tags subordinate xsd:appinfo). These documentation tags contain strings that may contain ampersands. I have written an XSL Document (.xls) to extract these values and output an XML document including them on the screen. When I copy and paste the result to an XML file (.xml) and test for well-formedness, I get an error telling me that a semicolon...
2
2126
by: gregmcmullinjr | last post by:
I am wondering if there is a way to use a DTD or Schema to instruct an XML parser to ignore tags that are not defined. That is, if my list of acceptable tags is <bodyand <content>, then in the following example: <body> We may have some text <b>and some <u>other tags</u></b> <contentbut I want the text and undefined tags to be part of the text-node
2
3856
by: Rami | last post by:
I am using an XSD schema to validate an XML document. I want to validate both XML structure and . When I try to validate the document, the validation only checks for things like proper tags, and correct data (like integer or string). So if I put any character in between tags that should embrace int then it will complain. But If I put value like 1000, between tags that should containa restrictted values like from 0 to 6 then I will get no...
3
1952
by: Michael | last post by:
If I come up with an XML Schema, do I own the intellectual propertyrights for that schema? Can I legally restrict others from using that schema? I'm in the UK if that makes any difference...
0
851
by: akshaychand | last post by:
Hi, I am designing a Schema Editor using the Schema Object Model in .NET 2.0. I am currently facing an problem wherein I want to list all the built-in data types as well as the custom types that are defined globally in the schema as well as the custom types that are defined globally in all the imported schemas. Basically, I want to list all these types in a drop down so that when user creates a new element or attribute, he can specify that...
0
9978
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
9821
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
11229
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
7169
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
5850
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
6042
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
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
2
4271
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3276
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.